Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

264
Visualizações
HTTP HEAD request giving ERR_STREAM_WRITE_AFTER_END error with node express

I have a health check route for my application which we use to check the application's health, it's a GET route but we send HTTP HEAD call to the same route but I am getting ERR_STREAM_WRITE_AFTER_END error. When digging into that I found out whenever I try to send response data for type HEAD call this error comes but couldn't find the actual reason for the same. Can someone explain why it's behaving this way? The sample code is given below.

Code with error, it's giving error even with res.json and res.send

router.get('/health', function (req, res) {
    res.send({
        message: "working great!!!"
    });
    res.end();
});

Update 1 -> After removing res.send, it's working fine, but still interested to know why by using res.send, it's giving the error. in HTTP HEAD call, client is working as expected it's ignoring response body but why on sever side, we are getting this error?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Remove the res.end() it might solve the issue

And you can try this

router.route("/health").get(function (req, res) {
    res.send({
        message: "working great!!!"
    });
    
});
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda