http-party/http-server

Server Crashing with "Cannot set headers after they are sent to the client"

Open

#634 aberto em 7 de jun. de 2020

Ver no GitHub
 (10 comments) (12 reactions) (0 assignees)JavaScript (1.497 forks)batch import
Hacktoberfestgood first issue

Métricas do repositório

Stars
 (13.088 stars)
Métricas de merge de PR
 (Nenhuma PRs mesclada em 30d)

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.

Guia do colaborador