Server Crashing with "Cannot set headers after they are sent to the client"
See original GitHub issueSteps to reproduce the issue, if applicable. Include the actual command and output and/or stack trace.
Not sure sorry as there is a lot of traffic on the server, just appears to all be normal GET requests.
What did you expect to happen? The server to not crash. Ideally the error would be returned as a 503.
_http_outgoing.js:485
throw new ERR_HTTP_HEADERS_SENT('set');
^
Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:485:11)
at module.exports.ResponseStream.<computed> [as setHeader] (C:\Users\Administrator\AppData\Roaming\npm\node_modules\http-server\node_modules\union\lib\response-stream.js:100:34)
at Object.exports.<computed> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\http-server\node_modules\ecstatic\lib\ecstatic\status-handlers.js:57:7)
at ReadStream.<anonymous> (C:\Users\Administrator\AppData\Roaming\npm\node_modules\http-server\node_modules\ecstatic\lib\ecstatic.js:298:24)
at ReadStream.emit (events.js:223:5)
at internal/fs/streams.js:167:12
at FSReqCallback.wrapper [as oncomplete] (fs.js:470:5) {
code: 'ERR_HTTP_HEADERS_SENT'
}
Tell us about your environment Windows Server 2016 Node.js v12.14.1 Latest Version (Embedded/Global CLI Version from NPM)
Other information (related issues, suggestions for a fix, etc): As far as I am aware the only thing that really needs to be done is catching the error and returning 503.
Issue Analytics
- State:
- Created 3 years ago
- Reactions:12
- Comments:11 (3 by maintainers)
Top Results From Across the Web
Error: Can't set headers after they are sent to the client
The error "Error: Can't set headers after they are sent." means that you're already in the Body or Finished state, but some function...
Read more >Understanding Node Error [ERR_HTTP_HEADERS_SENT]
This post describes why the Node Error [ERR_HTTP_HEADERS_SENT] cannot set headers after they are sent.
Read more >code: 'err_http_headers_sent' - You.com | The AI Search ...
The 'errhttpheaders_sent' error code is a runtime error that occurs when Node.js attempts to set headers after they have already been sent to...
Read more >Node.js HTTP: ERR_HTTP_HEADERS_SENT - Airbrake Blog
If you're receiving this error, this means that a part of your code is attempting to send a header after the body has...
Read more >Cannot set headers after they are sent to the client in JS
The "Cannot set headers after they are sent to the client" error occurs when the server in an express.js application sends more than...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Same issue. Rolling back to 13.0.2 worked
In my case it was happening for .json files, easy solution was to rollback to version 13.0.2