nuxt / cli

⚡️ Nuxt Generation CLI Experience.
https://github.com/nuxt/cli/discussions/3
MIT License
272 stars 67 forks source link

ERR_CONNECTION_REFUSED In a large application in dev mode #335

Open Flashantik opened 10 months ago

Flashantik commented 10 months ago

Environment


Reproduction

https://github.com/Flashantik/nuxt-3.10.-slow-dev-mode

Describe the bug

We have a large application, however after updating nuxt@3.7 dev mode started to slow down a lot and often cannot render all components I was able to recreate this behavior in a clean project with a lot of simple components...

To get the error all you need to do is run npm run dev and go to localhost:3000. Many components in the network will be in pending mode and after some time 500 error or ERR_CONNECTION_REFUSED error will be displayed. If there is no error in the console it is enough to reload the page.

build mode works fine. If you install nuxt@3.6.5 there are no such problems with dev mode.

Screenshot 2024-02-05 at 21 49 46

Additional context

No response

Logs

Client logs: 

vue-router.mjs:3471 TypeError: Failed to fetch dynamically imported module: http://localhost:3000/_nuxt/pages/index.vue
triggerError @ vue-router.mjs:3471
(anonymous) @ vue-router.mjs:3184
nuxt.js:98 [nuxt] error caught during app initial
[Vue Router warn]: uncaught error during route navigation:

[nuxt] error caught during app initialization TypeError: Failed to fetch dynamically imported module

Failed to load resource: net::ERR_CONNECTION_REFUSED
Failed to load resource: net::ERR_SOCKET_NOT_CONNECTED
Hydration class mismatch

Server Logs (sometimes) 

ERROR  [unhandledRejection] connect ETIMEDOUT 127.0.0.1:61574                                                   9:49:52 PM

  at TCPConnectWrap.afterConnect [as oncomplete] (node:net:1595:16)
ThomasBerneHCSE commented 8 months ago

Same problem occurs on nuxt 3.11.1 with nitropack 2.9.X

Flashantik commented 8 months ago

Same problem occurs on nuxt 3.11.1 with nitropack 2.8.X

Yes, but it's hardly a nitropack problem. nuxt@3.6.5 works fine with nitropack@2.8.1, but nuxt@3.7.0 with nitropack@2.8.1 is already slow and buggy. This continues on nuxt@3.11.1.

joaomarcelofm commented 8 months ago

This is happening in our project that isn't that big even (±400 components). It does indeed seem to be mainly a Nuxt issue, as @Flashantik pointed out in https://github.com/nuxt/nuxt/issues/23832.

Flashantik commented 8 months ago

This is happening in our project that isn't that big even (±400 components). It does indeed seem to be mainly a Nuxt issue, as @Flashantik pointed out in nuxt/nuxt#23832.

It's not just about the components, but also about composables, utils pages, and so on. Each file in dev mode is loaded separately on the network, I think this is the problem..

By the way, as a solution to the problem, I found using bun instead of node, it is capable of consistently delivering about 10,000 files

robinscholz commented 3 months ago

Facing the same problem!