nuxt
nuxt copied to clipboard
socket hang up when using file watchers
Environment
Nuxt CLI v3.0.0-27419629.87eb7d0 RootDir: D:\develop\nuxt3-app Nuxt project info:
- Operating System:
Windows_NT
- Node Version:
v16.11.1
- Nuxt Version:
3.0.0-27419629.87eb7d0
- Package Manager:
[email protected]
- Bundler:
Vite
- User Config:
css
,nitro
,vue
- Runtime Modules:
-
- Build Modules:
-
Reproduction
- If using IntelliJ install the plugin "File Watchers" and add a watcher for SCSS files. May also work with other IDEs.
- Create a .scss-file (e.g.
/assets/styles/main.scss
) - start Vite dev-server
- edit the created scss-file
Describe the bug
If using a file watcher for transpiling scss to css and then changing the scss, the watcher generates a new css file. When registering file changes (may be the change of the .scss file) Vite dev-server rebuilds its files and then the following error occurs.
I think the error occurs, because the filewatcher is writing the css-file while Vite dev-server tries to read it.
Additional context
No response
Logs
ERROR [proxy] socket hang up
at connResetException (node:internal/errors:691:14)
at Socket.socketOnEnd (node:_http_client:471:23)
at Socket.emit (node:events:402:35)
at Socket.emit (node:domain:475:12)
at endReadableNT (node:internal/streams/readable:1343:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
In addition: After "socket hang up" you have to restart the Vite dev server in order to refresh (F5) the page. Otherwise the page will load endless. But this happens after a few of these error messages. Couldn't figure out until now what is causing that issue.
I don't use scss and also have this problem
Do you use any other software that changes files while Vite might rebuild your project? Or can you provide more information on when this is happening to you, e.g. which files did you change?
This might help the developers to figure out the exact problem.
Do you use any other software that changes files while Vite might rebuild your project? Or can you provide more information on when this is happening to you, e.g. which files did you change?
This might help the developers to figure out the exact problem.
I can't give you too much useful information. It seems to me that the error occurs randomly. I am using pure Nuxt 3 + tailwindcss v3. Nothing more.
It's worth noting that I'm using nginx as an ssl proxy in dev mode.
i have this problem too
OS: ubuntu v20.04.2
Node Version: v16.13.1
NPM Version: v8.3.0
Bundler: Vite
also use scss
when have this problem, i start the app again with npm run dev
We encounter this issue too, sometimes right after having started the dev server. It seems that when the project grows, the error appears more often. (And we use stylus, no SCSS)
(And we use stylus, no SCSS)
But this has to be transpiled anyways? As I wrote in the opening post:
I think the error occurs, because the filewatcher is writing the css-file while Vite dev-server tries to read it.
So there seems to be a problem with multiple processes accessing the same file at the same time.
@ilouHD yes indeed. Do you really think this is a nuxt3 related issue then, or a Vite one only ?
At least it's the Vite dev-server that's causing the crash, so I think it should be Vite, but I'm not sure about this.
I have had this problem since the first version of Nuxt 3 beta (with Vite).
Basically, it can be fixed by a change (for example, by adding an empty space in the vue file) and it works again. But it's quite annoying during development. In my team, the socket hang up
is displayed several times an hour. Yuck ...
@danielroe @pi0 you have no idea where the problem may be?
It would be great to get rid of this long-standing bug. Thanks for response!
My log output:
ERROR [proxy] socket hang up
at connResetException (node:internal/errors:692:14)
at Socket.socketOnEnd (node:_http_client:478:23)
at Socket.emit (node:events:539:35)
at Socket.emit (node:domain:475:12)
at endReadableNT (node:internal/streams/readable:1345:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
Nuxt project info:
------------------------------
- Operating System: `Linux`
- Node Version: `v17.8.0`
- Nuxt Version: `3.0.0-27477996.646c2f6`
- Package Manager: `[email protected]`
- Builder: `vite`
- User Config: `modules`
- Runtime Modules: `normalizedModule()`, `normalizedModule()`
- Build Modules: `-`
------------------------------
What's the state on this? Transfer to vite? Close due to being upstream?
I think it can be closed IMO