Netlify DEV - Randomly getting TypeError: res.writeHead is not a function at ProxyServer

Hi,
out of nowhere I’m getting this weird error on localhost running netlify dev… it’s happening randomly, works for some time, then I’m getting this error and nothing works… tried reinstalling nodeJS, NPM and tried various versions… currently running node 16.17.0

I don’t know how to debug this, any help?

/Users/peteroravec/.nvm/versions/node/v16.17.0/lib/node_modules/netlify-cli/node_modules/netlify-redirector/lib/redirects.js:116
      throw ex;
      ^

TypeError: res.writeHead is not a function
    at ProxyServer.<anonymous> (/Users/peteroravec/.nvm/versions/node/v16.17.0/lib/node_modules/netlify-cli/src/utils/proxy.js:310:9)
    at ProxyServer.emit (/Users/peteroravec/.nvm/versions/node/v16.17.0/lib/node_modules/netlify-cli/node_modules/eventemitter3/index.js:204:33)
    at Socket.onOutgoingError (/Users/peteroravec/.nvm/versions/node/v16.17.0/lib/node_modules/netlify-cli/node_modules/http-proxy/lib/http-proxy/passes/ws-incoming.js:157:16)
    at Socket.emit (node:events:525:35)
    at Socket.emit (node:domain:489:12)
    at emitErrorNT (node:internal/streams/destroy:157:8)
    at emitErrorCloseNT (node:internal/streams/destroy:122:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21)

What version of CLI are you using? What site is this? Such issues are more useful if reported on:

Hi,
I updated to latest Netlify CLI… it helped little bit but this issue still there, website is https://eutxo2.netlify.app/

    "netlify": "12.0.1",
    "netlify-cli": "11.3.0",

Could you explain what you mean by “helped little bit”? It was my understanding that either netlify dev crashed or it didn’t, so what behavior are you seeing now, in some detail?

But before you answer that - could you re-update to the newest CLI? We’ve released version 11.5.0 by now :slight_smile:

Hey, I updated to

    "netlify": "12.0.1",
    "netlify-cli": "11.5.0",

but still getting these errors… basically it works for couple of minutes, then crash and keep crashing… most of the time now it not working…

/Users/peteroravec/.nvm/versions/node/v14.18.0/lib/node_modules/netlify-cli/node_modules/netlify-redirector/lib/redirects.js:116
      throw ex;
      ^

TypeError: res.writeHead is not a function
    at ProxyServer.<anonymous> (/Users/peteroravec/.nvm/versions/node/v14.18.0/lib/node_modules/netlify-cli/src/utils/proxy.js:311:9)
    at ProxyServer.emit (/Users/peteroravec/.nvm/versions/node/v14.18.0/lib/node_modules/netlify-cli/node_modules/eventemitter3/index.js:204:33)
    at Socket.onOutgoingError (/Users/peteroravec/.nvm/versions/node/v14.18.0/lib/node_modules/netlify-cli/node_modules/http-proxy/lib/http-proxy/passes/ws-incoming.js:157:16)
    at Socket.emit (events.js:412:35)
    at Socket.emit (domain.js:475:12)
    at emitErrorNT (net.js:1358:8)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)

Any suggestions?

Hi @peteroravec,

Are you able to share a repro case?

Hard to simulate this… it’s just randomly crash… but I did this…
I reinstalled my macbook and put there fresh instalation…

Installed
“netlify”: “12.0.1”,
“netlify-cli”: “11.5.0”,
“node”: “16.17.0”

Then tried to run it and BUM, same error… on first run on freshly installed computer…

Then I tried older version, netlify-cli@10.17.4 and it works better, I get also that error but maybe once per 3 hours of work…

So, I understand you can sometimes reproduce it, but we cannot, since we don’t have access to your source code :slight_smile:

Let’s try this instead:

  1. come up with the best reproduction case you have - you have versions up there, but not code that shows the problem or steps to trigger it once running, exactly.
  2. once you have that reproduction case - which you might make by whittling down your source code to the smallest thing that causes it, or by opening your repo so people can clone it and test it out for themeslves
  3. …you get a bug filed on our CLI: Issues · netlify/cli · GitHub

That’s what our team would have done for you, but we’ll let you take the lead since only you can access your source code today :slight_smile: