nuxt icon indicating copy to clipboard operation
nuxt copied to clipboard

socket hang up when using file watchers

Open MarcTroll opened this issue 3 years ago • 11 comments

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

  1. If using IntelliJ install the plugin "File Watchers" and add a watcher for SCSS files. May also work with other IDEs.
  2. Create a .scss-file (e.g. /assets/styles/main.scss)
  3. start Vite dev-server
  4. 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)

MarcTroll avatar Feb 22 '22 16:02 MarcTroll

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.

MarcTroll avatar Feb 22 '22 17:02 MarcTroll

I don't use scss and also have this problem

4Kazelot avatar Feb 22 '22 18:02 4Kazelot

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.

MarcTroll avatar Feb 22 '22 19:02 MarcTroll

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.

4Kazelot avatar Feb 23 '22 09:02 4Kazelot

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

the-pesar avatar Feb 25 '22 20:02 the-pesar

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)

qnp avatar Mar 05 '22 20:03 qnp

(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.

MarcTroll avatar Mar 05 '22 21:03 MarcTroll

@ilouHD yes indeed. Do you really think this is a nuxt3 related issue then, or a Vite one only ?

qnp avatar Mar 05 '22 22:03 qnp

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.

MarcTroll avatar Mar 05 '22 23:03 MarcTroll

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:    `-`
------------------------------

misaon avatar Mar 31 '22 07:03 misaon

What's the state on this? Transfer to vite? Close due to being upstream?

madebyfabian avatar Feb 06 '23 22:02 madebyfabian

I think it can be closed IMO

atinux avatar Feb 20 '23 10:02 atinux