Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

266
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!