Skip to content

Commit 04bbcd6

Browse files
committed
use current scope rather than pushing a new one on the stack
1 parent 1a9e6f6 commit 04bbcd6

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/nextjs/src/utils/handlers.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Scope } from '@sentry/hub';
2-
import { captureException, flush, getCurrentHub, Handlers, startTransaction, withScope } from '@sentry/node';
2+
import { captureException, flush, getCurrentHub, Handlers, startTransaction } from '@sentry/node';
33
import { extractTraceparentData, getActiveTransaction, hasTracingEnabled } from '@sentry/tracing';
44
import { addExceptionMechanism, isString, logger, stripUrlQueryAndFragment } from '@sentry/utils';
55
import * as domain from 'domain';
@@ -78,15 +78,15 @@ export const withSentry = (handler: NextApiHandler): WrappedNextApiHandler => {
7878
try {
7979
return await handler(req, res); // Call original handler
8080
} catch (e) {
81-
withScope(scope => {
82-
scope.addEventProcessor(event => {
81+
if (currentScope) {
82+
currentScope.addEventProcessor(event => {
8383
addExceptionMechanism(event, {
8484
handled: false,
8585
});
8686
return parseRequest(event, req);
8787
});
8888
captureException(e);
89-
});
89+
}
9090
throw e;
9191
}
9292
});

0 commit comments

Comments
 (0)