Skip to content

Commit 0fd09a8

Browse files
committed
report errorMiddleware errors as unhandled
I found it confusing that unhandled errors caught by the express.js middleware were being reported as handled This change updates the behavior to match Sentry-Python's Django integration: https://github.com/getsentry/sentry-python/blob/81afcea403c0ac148d631164de29ed80d6a64840/sentry_sdk/integrations/asgi.py#L58
1 parent cf8c072 commit 0fd09a8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

packages/node/src/handlers.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
import type { Span } from '@sentry/types';
1111
import type { AddRequestDataToEventOptions } from '@sentry/utils';
1212
import {
13+
addExceptionMechanism,
1314
addRequestDataToTransaction,
1415
baggageHeaderToDynamicSamplingContext,
1516
dropUndefinedKeys,
@@ -304,6 +305,11 @@ export function errorHandler(options?: {
304305
}
305306
}
306307

308+
_scope.addEventProcessor(event => {
309+
addExceptionMechanism(event, { type: 'middleware', handled: false });
310+
return event;
311+
});
312+
307313
const eventId = captureException(error);
308314
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
309315
(res as any).sentry = eventId;

0 commit comments

Comments
 (0)