Server Crashing with "Cannot set headers after they are sent to the client"
#634 ouverte le 7 juin 2020
Métriques du dépôt
- Stars
- (13 088 stars)
- Métriques de merge PR
- (Aucune PR mergée en 30 j)
Description
Steps 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.