-
Notifications
You must be signed in to change notification settings - Fork 29.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
http module error out while sending empty response body #3269
Comments
I may just be misunderstanding your question but I don't see anything in the behavior you describe that suggests there is a problem with the If you want someone to review your code above to suggest improvements or find possible bugs, you might be better served filing the issue in https://github.com/nodejs/help/issues. If discussion there reveals that there is a bug in I'm going to close this issue, but if you think I'm just misunderstanding what you're trying to ask, feel free to re-open. |
Thank you Trott for the reply. Hope I am clear with my issue . |
If I'm understanding what correctly, the problem is that when A few things:
If a |
res.status(response.statusCode).send() will definitely crash if response is undefined so response = response || {} is the workaround for that and the code is breaking because we are trying to call res.status(null).send({}). as the status field is undefined node is breaking. |
I'm sorry but this is not the correct forum for this. |
Thank you very much for your help. |
As per express community , this looks like a nodejs issue. expressjs/express#2775 (comment) Please comment. |
You mean Doug's comment?
Personally, I'd say it's a case of GIGO. |
Yes, I agree . Thanks |
Please consider below test case:
file test.js
If I will run this program and hit http://localhost:3000/test_1 I am getting below error:
Possible reason:
request time out is 10ms where as /test_2 return the response after 100ms so request module stop waiting for http response and return to call back with err = " ETIMEDOUT", response and data = undefined.
To stop breaking the code I have added
But code is breaking while sending the body.
Work around:
Note change :
response = response || {"statusCode" : 500};
With this change code is running fine.
Please let me know if I am doing anything wrong here or if there is any issue in http module.
Thanks
The text was updated successfully, but these errors were encountered: