Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] handler.mjs: Comparison with -0 using the "===" operator will also match 0 [equals-negative-zero] #321

Open
LubomirGeorgiev opened this issue Feb 2, 2025 · 9 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@LubomirGeorgiev
Copy link

Describe the bug

When I build the app I get this warning:

▲ [WARNING] Comparison with -0 using the "===" operator will also match 0 [equals-negative-zero]

    .open-next/server-functions/default/handler.mjs:95787:47:
      95787 │                                 else if (t === -0) {

Steps to reproduce

Go to https://github.com/LubomirGeorgiev/cloudflare-workers-nextjs-saas-template/actions/runs/13103167050/job/36553955672#step:8:137

Expected behavior

Build without warnings

@opennextjs/cloudflare version

0.4.3

Wrangler version

3.107.2

next info output

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 24.3.0: Thu Jan  2 20:24:24 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6030
  Available memory (MB): 36864
  Available CPU cores: 11
Binaries:
  Node: 22.6.0
  npm: 10.8.2
  Yarn: N/A
  pnpm: 9.12.1
Relevant Packages:
  next: 14.2.23 // An outdated version detected (latest is 15.1.6), upgrade is highly recommended!
  eslint-config-next: 14.2.23
  react: 18.3.1
  react-dom: 18.3.1
  typescript: 5.7.3
Next.js Config:
  output: N/A
 ⚠ An outdated version detected (latest is 15.1.6), upgrade is highly recommended!
   Please try the latest canary version (`npm install next@canary`) to confirm the issue still exists before creating a new issue.
   Read more - https://nextjs.org/docs/messages/opening-an-issue

Additional context

No response

@LubomirGeorgiev LubomirGeorgiev added bug Something isn't working triage labels Feb 2, 2025
@vicb vicb removed the triage label Feb 3, 2025
@vicb
Copy link
Contributor

vicb commented Feb 3, 2025

The faulty code is in [email protected]_@[email protected]_@[email protected][email protected][email protected][email protected]/node_modules/next/dist/compiled/node-fetch/index.js.

While we could silence it, it doesn't sound right.

The better fix would be to investigate and submit a fix upstream

@vicb vicb added enhancement New feature or request help wanted Extra attention is needed and removed bug Something isn't working labels Feb 3, 2025
@nrjrajpal
Copy link

Can someone please tell me how this issue can be resolved? I am new to Cloudflare, and I am unable to build my application because of this. I really appreciate any help you can provide.

@vicb
Copy link
Contributor

vicb commented Feb 7, 2025

Can someone please tell me how this issue can be resolved? I am new to Cloudflare, and I am unable to build my application because of this. I really appreciate any help you can provide.

This should not prevent building your app, it's only a warning.

You can open an issue on the next.js repo to get this fixed, ===-0 is in their compiled version of node-fetch

@nrjrajpal
Copy link

nrjrajpal commented Feb 9, 2025

Hello,
Sorry, I should have clarified the issue properly. I am trying to deploy a nextjs project on Cloudflare workers. I have tried a bunch of different things, and I have made a bunch of different projects. In this one, I asked ChatGPT to make a basic app, that will take a name, send it to an API route, and append it to "Hello, ". Then I followed the steps on this: https://developers.cloudflare.com/workers/frameworks/framework-guides/nextjs/
Now, I have been able to build the projects using "npm run build", and they work fine. But when I run the "npm run preview:worker" command, even after deleting the .next and .open-next folders, I get this:

npm run preview:worker

> [email protected] preview:worker
> npm run build:worker && npm run dev:worker


> [email protected] build:worker
> opennextjs-cloudflare


┌─────────────────────────────┐
│ OpenNext — Cloudflare build │
└─────────────────────────────┘

WARN OpenNext is not fully compatible with Windows.
WARN For optimal performance, it is recommended to use Windows Subsystem for Linux (WSL).
WARN While OpenNext may function on Windows, it could encounter unpredictable failures during runtime.
App directory: C:\temp_neeraj\cloudflare_next_trial\workers-next-gpt-trial
Next.js version : 15.1.6
@opennextjs/cloudflare version: 0.4.7
@opennextjs/aws version: https://pkg.pr.new/@opennextjs/aws@727

┌─────────────────────────────────┐
│ OpenNext — Building Next.js app │
└─────────────────────────────────┘


> [email protected] build
> next build

   ▲ Next.js 15.1.6

   Creating an optimized production build ...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types    
 ✓ Collecting page data
 ✓ Generating static pages (6/6)
 ✓ Collecting build traces
 ✓ Finalizing page optimization    

Route (app)                              Size     First Load JS
┌ ○ /                                    575 B           106 kB
├ ○ /_not-found                          979 B           106 kB
└ ƒ /api/hello                           136 B           105 kB
+ First Load JS shared by all            105 kB
  ├ chunks/4bd1b696-692f10ba759dfb60.js  52.9 kB
  ├ chunks/517-7ba66467149c8b06.js       50.5 kB
  └ other shared chunks (total)          1.95 kB


○  (Static)   prerendered as static content
ƒ  (Dynamic)  server-rendered on demand


┌──────────────────────────────┐
│ OpenNext — Generating bundle │
└──────────────────────────────┘

Bundling middleware function...
Bundling static assets...
Bundling cache assets...
Building server function: default...
# copyPackageTemplateFiles
⚙️ Bundling the OpenNext server...

Applying code patches:
 - patching require
 - patching `buildId` function
 - patching `loadManifest` function
 - patching `findDir` function
 - patching `evalManifest` function
 - patching cacheHandler
 - patching 'require(this.middlewareManifestPath)'
 - patching exception bubbling
 - patching `patchAsyncStorage` call
 - patching `require.resolve` call
All 10 patches applied

Worker saved in `C:\temp_neeraj\cloudflare_next_trial\workers-next-gpt-trial\.open-next\worker.js` ��

OpenNext build complete.

> [email protected] dev:worker
> wrangler dev --port 8771


 ⛅️ wrangler 3.107.3
--------------------

Your worker has access to the following bindings:
- KV Namespaces:
  - NEXT_CACHE_WORKERS_KV: fd2c71aabc13489fa593a1af6ab614df (local)
[wrangler:inf] Ready on http://127.0.0.1:8771
▲ [WARNING] Comparison with -0 using the "===" operator will also match 0 [equals-negative-zero]

    .open-next/server-functions/default/handler.mjs:153562:31:
      153562 │               } else if (t === -0) {
             ╵                                ~~

  Floating-point equality is defined such that 0 and -0 are equal, so "x === -0" returns true for both 0 and -0. You need to use "Object.is(x, -0)" instead to test for -0.


⎔ Starting local server...
X [ERROR] service core:user:workers-next-gpt-trial: Uncaught Error: Unknown loadManifest: /.next/server/next-font-manifest.json

    at null.<anonymous> (worker.js:130681:13) in loadManifest
    at null.<anonymous> (worker.js:240770:47) in getNextFontManifest
    at null.<anonymous> (worker.js:128693:38) in Server
    at null.<anonymous> (worker.js:240170:9) in NextNodeServer
    at null.<anonymous> (worker.js:242720:22)



X [ERROR] The Workers runtime failed to start. There is likely additional logging output above.


If you think this is a bug then please create an issue at https://github.com/cloudflare/workers-sdk/issues/new/choose
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
🪵  Logs were written to "C:\Users\Admin\AppData\Roaming\xdg.config\.wrangler\logs\wrangler-2025-02- 09_12-07-00_536.log"
╭──────────────────────────────────────────────────────────────────────────────────────────────────╮
│  [b] open a browser, [d] open devtools, [l] turn off local mode, [c] clear console, [x] to exit  │
╰──────────────────────────────────────────────────────────────────────────────────────────────────╯

Here is the repo with my code: https://github.com/nrjrajpal/workers-next-gpt-trial

Please help me if possible, thanks.

@vicb
Copy link
Contributor

vicb commented Feb 18, 2025

@nrjrajpal Could you please open a different issue.

@vicb
Copy link
Contributor

vicb commented Feb 18, 2025

@nrjrajpal this should hopefully be fixed by #394 that will go into the next release

@LubomirGeorgiev
Copy link
Author

@nrjrajpal It's not this error that's blocking your build

@LubomirGeorgiev
Copy link
Author

@vicb I accidentally closed the issue and I can't open it back up

@logandx
Copy link

logandx commented Feb 19, 2025

i have the same issue on windows

@opennextjs opennextjs locked as off-topic and limited conversation to collaborators Feb 19, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request help wanted Extra attention is needed
Development

No branches or pull requests

5 participants