netlify / netlify/cli

Netlify dev server crashes upon saving code changes

Open
#5,917 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

type: bug
Dominant language
TypeScript
Stars
1.9k
Forks
474
Avg merge
23h 30m
Merged PRs (30d)
53

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with netlify dev while saving changes or switching branches, then inspect src/utils/proxy.mjs around line 362, where the reported res.writeHead error occurs. Compare the reload and error-handling paths for the development server. Done means the server remains running through code, CSS, and branch changes without the reported crash.

Written by the indexing model from the issue text.

Assessment

Tech stack
node.js, typescript
Domain
cli, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.