Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.9.2
Framework Version
Hapi 21.3.10
Link to Sentry event
No response
SDK Setup/Reproduction Example
I did some debugging and found that the issue can be fixed by specifying the 'error' channel here, like this:
server.events.on({name:'request', channels: ['error']}, (request, event) => {
Otherwise, an internal channel event occurs and that event is apparently too soon in the request lifecycle. I figured this out by comparing with hapi-sentry (code).
I believe this is enough for a minimal reproducible example:
Sentry.init();
Sentry.setupHapiErrorHandler(server);
server.ext('onPreResponse', (response, h) => {
throw Boom.notFound();
});
Steps to Reproduce
- Send a request where the route handler throws an Error
- The onPreResponse hook replaces the error with a Boom error
Expected Result
No error is reported to Sentry since Boom error responses do not generate Hapi response error events. And the error thrown from the handler should not be considered uncaught.
Actual Result
The Error thrown from the handler is reported to Sentry.
Is there an existing issue for this?
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/node
SDK Version
8.9.2
Framework Version
Hapi 21.3.10
Link to Sentry event
No response
SDK Setup/Reproduction Example
I did some debugging and found that the issue can be fixed by specifying the
'error'channel here, like this:Otherwise, an
internalchannel event occurs and that event is apparently too soon in the request lifecycle. I figured this out by comparing with hapi-sentry (code).I believe this is enough for a minimal reproducible example:
Steps to Reproduce
Expected Result
No error is reported to Sentry since Boom error responses do not generate Hapi response error events. And the error thrown from the handler should not be considered uncaught.
Actual Result
The Error thrown from the handler is reported to Sentry.