netlify / cli

Netlify Command Line Interface
http://cli.netlify.com
MIT License
1.57k stars 346 forks source link

Netlify dev server crashes upon saving code changes #5917

Open fadingbeat opened 1 year ago

fadingbeat commented 1 year ago

Describe the bug

If development server is running and I create a change in the code, upon saving those changes the server crashes. It also crashes if I switch between Git branches. The instance of application is running in the browser constantly. There are a couple of scenarios I've noticed this happening.

Steps to reproduce

Using VS Code Using Netlify serverless functions

Scenarion 1:

1. Run `netlify dev`
2. App is started in the browser, everything works as expected
3. Change something in the code and save it
4. Dev server crashes with message `res.writeHead is not a function`

Scenario 2:

1. Run `netlify dev `
2. App is started in the browser, everything works as expected
3. Commit changes
4. Switch between branches
5. Dev server crashes with message `res.writeHead is not a function`

Scenario 3:

1. Netlify server running
2. Change CSS styles
3. Server crashes
4. Run `netlify dev`
5. Reload browser
6. Server crashes
TypeError: res.writeHead is not a function
            at ProxyServer.<anonymous> (file:///C:/Development/color-healing/node_modules/netlify-cli/src/utils/proxy.mjs:362:9)
            at ProxyServer.emit (C:\Development\color-healing\node_modules\netlify-cli\node_modules\eventemitter3\index.js:204:33)
            at Socket.onOutgoingError (C:\Development\color-healing\node_modules\netlify-cli\node_modules\http-proxy\lib\http-proxy\passes\ws-incoming.js:157:16)  
            at Socket.emit (node:events:524:35)
            at Socket.emit (node:domain:489:12)
            at emitErrorNT (node:internal/streams/destroy:151:8)
            at emitErrorCloseNT (node:internal/streams/destroy:116:3)
            at processTicksAndRejections (node:internal/process/task_queues:82:21)

        Node.js v19.6.0
        fatal error: all goroutines are asleep - deadlock!

Configuration

[build]
  command = "npm run build"
  functions = "functions"
  publish = "dist/color-healing"
[functions]
  node_bundler = "esbuild"
[dev]
  autoLaunch = false
[[redirects]]
  from = "/*"
  to = "/"
  status = 200

Environment

System:
    OS: Windows 10 10.0.19045
    CPU: (4) x64 AMD A10-7300 Radeon R6, 10 Compute Cores 4C+6G
    Memory: 4.16 GB / 9.95 GB
  Binaries:
    Node: 19.6.0 - C:\Program Files\nodejs\node.EXE
    npm: 9.4.0 - C:\Program Files\nodejs\npm.CMD
  npmPackages:
    netlify-cli: 15.1.0 => 15.1.0
bdefore commented 1 year ago

I'm also encountering this, and have been for a while (https://answers.netlify.com/t/netlify-dev-randomly-getting-typeerror-res-writehead-is-not-a-function-at-proxyserver/73639/14) but it seems to be more frequent now.

fadingbeat commented 1 year ago

It's too often and became frustrating. Basically, I have to run the server every time I make a change to the code.

dustb0wl commented 1 year ago

+1 on this issue. I keep getting: TypeError: res.writeHead is not a function at random intervals and when editing files. It makes using the CLI impossible. I'm experiencing the issue in both next and gatsby projects.