-
-
Notifications
You must be signed in to change notification settings - Fork 16.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
Cannot use res in unhandled errors if produced error with resp.status() #4148
Comments
Hi there! Can you share a code sample and the error you are getting, please. This would help us troubleshoot the issue. |
how to produce the issue :
Since I am providing an undefined code to
|
We tried to fix this in 4.17.0, but had to revert in 4.17.1 due to it breaking existing apps. |
Ultimately, there is no guarantee you can send a response from the express error handler, as the response may no longer be in a good state. In your case, setting status to undefined causes the core node.js code to get into a bad state and node.js will no longer allow you to respond. |
Ohh okay. Thanks for your help |
Issue:
I am using an unhandled error handler in express. Now I am facing an issue when I try to send a response (somewhere in the code) and give an undefined status code, it fails as it should and throw an error which is then intercepted by the unhandled error handler.
Everything is working the way it should except now the unhandled error handler cannot send a response back to user using res anymore. It is just skipping over it.
The issue only persist when using undefined status code in the res beforehand.
The text was updated successfully, but these errors were encountered: