Open bdefore opened 11 months ago
@ericapisani i believe the FIXME was not present until your recent TS migration https://github.com/netlify/cli/pull/6136 ... did you explore this or maybe have any insight?
My main development is on a desktop with 32GB of RAM. I noticed that this issue occurred almost constantly on a laptop with half of that. I've today upgraded the desktop to 64GB of RAM and the error has yet to occur in the moments I would typically encounter it. Running top
on the desktop shows that running my Netlify Dev uses up to 8GB, and alongside a TestCafe test runner can peak around 13GB.
This does not excuse the proxy error, but it does indicate that underprovisioned hardware may be more prone to experience the issue. To those who might be experiencing this, try either reducing memory usage or upgrading.
Describe the bug
I have for a year now intermittently gottten crashes from Netlify Dev. My initial comment on this is here: https://answers.netlify.com/t/netlify-dev-randomly-getting-typeerror-res-writehead-is-not-a-function-at-proxyserver/73639/12
As I mention there, I believe Netlify Dev's proxy implementation calls
writeHead
on the response when that function may not exist, such as if the response is via web socket. As a result, the dev server crashes, sometimes leaving other processes running. In my case, those processes are related to the create-react-app webpack server, for which I have to manually kill in order to properly restart Netlify Dev.I notice that there was a couple days ago a substantial TypeScript migration, including to the proxy source file. In that update there is a note with a FIXME that looks related: https://github.com/netlify/cli/blob/main/src/utils/proxy.mts#L457 . I'll copy the related source here:
A potential solution would be to skip adding the content-type header if
writeHead
does not exist onres
.Some related issues: https://github.com/netlify/cli/issues/5676 https://github.com/netlify/cli/issues/5917 https://github.com/netlify/cli/issues/6025
Here is the output I encounter from the dev server as it crashes:
Steps to reproduce
Unfortunately, I cannot share my source and cannot consistently reproduce the crash. I have not been able to reproduce in a minimal project from scratch. It appears to occur more frequently when I am calling particular Netlify Functions, but that may be unrelated.
Configuration
Partial netlify.toml:
The
pnpm start:dev
command is callingreact-scripts start
Environment
System: OS: Linux 6.5 Manjaro Linux CPU: (16) x64 AMD Ryzen 7 5800X3D 8-Core Processor Memory: 28.31 GB / 31.25 GB Container: Yes Shell: 5.2.15 - /bin/bash Binaries: Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node Yarn: 1.22.21 - ~/.nvm/versions/node/v20.9.0/bin/yarn npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm pnpm: 8.10.5 - ~/.nvm/versions/node/v20.9.0/bin/pnpm npmGlobalPackages: netlify-cli: 17.4.0