Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

263
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda