Skip to content

Commit f603014

Browse files
committed
feat: handled false for onServerError
1 parent 7404654 commit f603014

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

packages/next-plugin-sentry/src/on-error-server.js

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,28 @@ export default async function onErrorServer(err) {
99

1010
withScope(scope => {
1111
if (typeof err.req !== 'undefined') {
12-
scope.addEventProcessor(event =>
13-
parseRequest(event, err.req, {
12+
scope.addEventProcessor((event, hint) => {
13+
console.log(hint);
14+
return parseRequest(event, err.req, {
1415
// 'cookies' and 'query_string' use `dynamicRequire` which has a bug in SSR envs right now — Kamil
1516
request: ['data', 'headers', 'method', 'url'],
16-
}),
17-
);
17+
});
18+
});
1819
}
19-
captureException(err instanceof Error ? err : err.err);
20+
21+
const toCapture = err instanceof Error ? err : err.err;
22+
23+
scope.addEventProcessor((event, hint) => {
24+
if (hint.originalException === toCapture) {
25+
event.exception.values[0].mechanism = {
26+
handled: false,
27+
type: "onErrorServer"
28+
}
29+
}
30+
return event;
31+
});
32+
33+
captureException(toCapture);
2034
});
2135

2236
await flush(sentryTimeout);

0 commit comments

Comments
 (0)