Skip to content

Commit db50399

Browse files
committed
fix: Set handled:false for next.js serverless
1 parent 3fbe529 commit db50399

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

packages/nextjs/src/utils/handlers.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { captureException, flush, Handlers, withScope } from '@sentry/node';
2+
import { addExceptionMechanism } from '@sentry/utils';
23
import { NextApiRequest, NextApiResponse } from 'next';
34

45
const { parseRequest } = Handlers;
@@ -13,11 +14,17 @@ export const withSentry = (handler: (req: NextApiRequest, res: NextApiResponse)
1314
// TODO: Finish Transaction
1415
} catch (e) {
1516
withScope(scope => {
16-
scope.addEventProcessor(event => parseRequest(event, req));
17+
scope.addEventProcessor(event => {
18+
addExceptionMechanism(event, {
19+
handled: false,
20+
});
21+
return parseRequest(event, req);
22+
});
1723
captureException(e);
1824
});
19-
await flush(2000);
2025
throw e;
26+
} finally {
27+
await flush(2000);
2128
}
2229
};
2330
};

0 commit comments

Comments
 (0)