Description
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
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 to next
. 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 to next
. 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.