naxodev / oss

Open Source Software (OSS) projects by naxodev
https://naxo.dev
MIT License
19 stars 1 forks source link

Serve command timeout issue after upgrade (v2.2.0) #58

Closed mnlbox closed 3 months ago

mnlbox commented 3 months ago

Hi @NachoVazquez

I upgraded some of my packages and it seems all cloudflare workder projects that I have this monorepo stopped working. I don't have any error and I'm getting server is running like this:

Connecting on 127.0.0.1:4002

 ⛅️ wrangler 3.67.1
-------------------

⎔ Starting local server...
[wrangler:inf] Ready on http://localhost:4002
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit                           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
Connecting on 127.0.0.1:4002

But all request that I'm sending via Postman timeout after a long waiting. Any idea?

Steps to Reproduce

I even tried to test with a fresh new project but it seems the combination of packages with the versions mentioned below is not working.

Nx Report

pnpm nx report

 NX   Report complete - copy this into the issue template

Node   : 20.14.0
OS     : linux-arm64
pnpm   : 9.6.0

nx                 : 18.3.3
@nx/js             : 18.3.3
@nx/jest           : 18.3.3
@nx/linter         : 18.3.3
@nx/eslint         : 18.3.3
@nx/workspace      : 18.3.3
@nx/devkit         : 18.3.3
@nx/esbuild        : 18.3.3
@nx/eslint-plugin  : 18.3.3
@nx/nest           : 18.3.3
@nx/node           : 18.3.3
@nx/playwright     : 18.3.3
@nx/react          : 18.3.3
@nrwl/tao          : 18.3.3
@nx/vite           : 18.3.3
@nx/web            : 18.3.3
@nx/webpack        : 18.3.3
typescript         : 5.5.4
---------------------------------------
Registered Plugins:
@nx/webpack/plugin
@nx/eslint/plugin
@nx/vite/plugin
@nx/playwright/plugin
---------------------------------------
Community plugins:
@naxodev/nx-cloudflare : 2.2.0

Failure Logs

No response

Operating System

Additional Information

I'm using Linux in a Mac with VsCode devContainer

NachoVazquez commented 3 months ago

Hey @mnlbox, thanks for creating this issue. I will take a look today.

NachoVazquez commented 3 months ago

@mnlbox, the latest version of this package only supports Nx ^19.0.0; your workspace is using Nx 18.3, which, depending on your package manager, can try to install both versions of nx simultaneously, which could cause weird issues. I cannot guarantee that's the issue here. But it doesn't help.

NachoVazquez commented 3 months ago

Please create a reproduction of the problem and share it here so I can be more helpful. I was not able to reproduce it locally.

mnlbox commented 3 months ago

I'm currently using "@naxodev/nx-cloudflare : 2.2.0" based on the table here it's the version that working with Nx 18:

image
NachoVazquez commented 3 months ago

Thanks; I missed that. I thought you were using the last one.

NachoVazquez commented 3 months ago

I attempted to replicate the issue in a new repository but was unsuccessful. I would greatly appreciate your help in creating a reproduction so I can figure out a possible plugin issue.

mnlbox commented 3 months ago

I tried to test my app directly with wrangler command but I got timeout error like this:

pnpm wrangler dev services/test/src/index.ts

 ⛅️ wrangler 3.67.1
-------------------

[wrangler:inf] Ready on http://localhost:8787
⎔ Starting local server...
╭──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ [b] open a browser, [d] open Devtools, [l] turn off local mode, [c] clear console, [x] to exit                           │
╰──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
/mytest/node_modules/.pnpm/wrangler@3.67.1_@cloudflare+workers-types@4.20240524.0/node_modules/wrangler/wrangler-dist/cli.js:29765
            throw a;
            ^

TypeError: fetch failed
    at Object.fetch (/mytest/node_modules/.pnpm/undici@5.28.4/node_modules/undici/index.js:112:15)
    at async fetch3 (/mytest/node_modules/.pnpm/miniflare@3.20240718.1/node_modules/miniflare/dist/src/index.js:4303:20)
    at async Miniflare2.dispatchFetch (/mytest/node_modules/.pnpm/miniflare@3.20240718.1/node_modules/miniflare/dist/src/index.js:9332:22)
    at async Mutex.runWith (/mytest/node_modules/.pnpm/miniflare@3.20240718.1/node_modules/miniflare/dist/src/index.js:3521:16)
    at async ProxyController.sendMessageToProxyWorker (/mytest/node_modules/.pnpm/wrangler@3.67.1_@cloudflare+workers-types@4.20240524.0/node_modules/wrangler/wrangler-dist/cli.js:209940:7) {
  cause: HeadersTimeoutError: Headers Timeout Error
      at Timeout.onParserTimeout [as callback] (/mytest/node_modules/.pnpm/undici@5.28.4/node_modules/undici/lib/client.js:1048:28)
      at Timeout.onTimeout [as _onTimeout] (/mytest/node_modules/.pnpm/undici@5.28.4/node_modules/undici/lib/timers.js:20:13)
      at listOnTimeout (node:internal/timers:573:17)
      at process.processTimers (node:internal/timers:514:7) {
    code: 'UND_ERR_HEADERS_TIMEOUT'
  }
}

Node.js v20.14.0
mnlbox commented 3 months ago

It seems it's related to "@cloudflare/workers-types" package. Which version of "@cloudflare/workers-types" package should I use with "@naxodev/nx-cloudflare" package?

NachoVazquez commented 3 months ago

For that version ^4.20240419.0 but "@cloudflare/workers-types," as its name indicates, are just types. It should not affect the runtime.

Try with this version of wrangler "wrangler": "^3.48.0",

mnlbox commented 3 months ago

I don't know why but after adding ip config to the serve command now it's working. So this one is not working and stuck when I try to serve it:

"serve": {
      "executor": "@naxodev/nx-cloudflare:serve",
      "options": {
        "port": 4001
      }
    },

But this one is working without any issue.

"serve": {
      "executor": "@naxodev/nx-cloudflare:serve",
      "options": {
        "port": 4001,
        "ip": "127.0.0.1"            <--------------- I added this and it's working now
      }
    },

I don't know maybe it's a docker issue. 🤔

mnlbox commented 3 months ago

OK it seems it's a docker issue started from v 26.0.0

https://github.com/moby/moby/releases/tag/v26.0.0

So we should mention "ip": "127.0.0.1" otherwise it will use IPv6. Same issue for Vite here: https://github.com/vitejs/vite/issues/16522#issuecomment-2084322973

NachoVazquez commented 3 months ago

Great finding @mnlbox ! I'm glad you found a solution.

I will close this one now, but please let me know if you have any future issues or suggestions for improving the plugin! I hope you have a great week.

mnlbox commented 2 months ago

Sure, I'll create more Hono projects with your awesome tool next week. Hope to switch to the latest version and I'll back to you if I faced any issue.