-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Uncaught async middleware error crashing server #6689
Comments
Hey @sderrow thanks for writing in! Please see #5931 (comment) on more details on why async exceptions work this way See #6137 (comment) for some more details. To grab a snippet: As per the Node docs if an unhandled rejection is triggered the process should be exited: https://nodejs.org/api/process.html#warning-using-uncaughtexception-correctly. In this case, the default behavior is to exit the process, and if you register a custom handler, you should also be exiting the process. Since Sentry is registering a custom handler, we are exiting the process as a result.
You can set the |
Thanks for the quick response, @AbhiPrasad! Not sure the With Sentry enabled, |
Ahh I see, that makes this clearer. It's not Sentry's responsibility here to forward the error to The Sentry SDK shouldn't be forwarded errors to |
For sure, but |
This issue has gone three weeks without activity. In another week, I will close it. But! If you comment or otherwise update it, I will reset the clock, and if you label it "A weed is but an unloved flower." ― Ella Wheeler Wilcox 🥀 |
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which package are you using?
@sentry/node
SDK Version
7.29.0
Framework Version
No response
Link to Sentry event
No response
Steps to Reproduce
Here's a CodeSandbox demo of the situation.
Brief summary:
I'm using
express-async-errors
in order to catch errors that are thrown in async handler and automatically forward tonext
. This was working fine through sentry-javascript version 7.11.1 (Aug 2022). Starting with 7.12.0 up to the latest release (7.29.0), Sentry's wrappers are somehow overwriting the auto-forwarding of thrown errors in async middleware, so any errors are uncaught and crash the server. Furthermore, the behavior is not even consistent. If the async middleware is added directly as part of a route declaration, then errors within that middleware will still be forwarded. It's only when the middleware is added to an entire express router (see the CodeSandbox demo).Expected Result
Ideally, Sentry's SDK would not interfere with
express-async-errors
so that errors thrown in async middleware can be caught and forwarded tonext
. But at a minimum, the behavior should be consistent between router and route middlewares.Actual Result
Server is crashed when errors are thrown in async middleware preceding routers.
The text was updated successfully, but these errors were encountered: