Skip to content

Commit 69d57da

Browse files
committed
[v7] Remove raven-node backward-compat code from node rejection handler
1 parent 14200d1 commit 69d57da

File tree

1 file changed

+7
-30
lines changed

1 file changed

+7
-30
lines changed

packages/integration-node-globalhandlers/src/onunhandledrejection.ts

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ClientLike, Integration, ScopeContext } from '@sentry/types';
1+
import { ClientLike, Integration } from '@sentry/types';
22
import { consoleSandbox } from '@sentry/utils';
33

44
import { logAndExitProcess } from './exit';
@@ -7,10 +7,6 @@ type UnhandledRejectionMode = 'none' | 'warn' | 'strict';
77
type OnUncaughtExceptionOptions = {
88
mode?: UnhandledRejectionMode;
99
};
10-
type PromiseRejectionWithDomainContext = {
11-
domain?: { sentryContext?: ScopeContext };
12-
};
13-
1410
const DEFAULT_REJECTION_MODE = 'warn';
1511

1612
export class OnUnhandledRejection implements Integration {
@@ -23,31 +19,12 @@ export class OnUnhandledRejection implements Integration {
2319
global.process.on('unhandledRejection', handler);
2420
}
2521

26-
public _makeRejectionHandler(
27-
client: ClientLike,
28-
): (reason: { stack?: string }, promise: PromiseRejectionWithDomainContext) => void {
29-
return (reason: { stack?: string }, promise: PromiseRejectionWithDomainContext): void => {
30-
const context = promise.domain?.sentryContext || {};
31-
32-
const scope: ScopeContext = { extra: { unhandledPromiseRejection: true } };
33-
34-
// TODO: Validate whether its still necessary to keep it
35-
// Preserve backwards compatibility with raven-node for now
36-
if (context.user) {
37-
scope.user = context.user;
38-
}
39-
if (context.tags) {
40-
scope.tags = context.tags;
41-
}
42-
if (context.extra) {
43-
scope.extra = {
44-
...scope.extra,
45-
...context.extra,
46-
};
47-
}
48-
49-
client.captureException(reason, { hint: { originalException: promise }, scope });
50-
22+
public _makeRejectionHandler(client: ClientLike): (reason: { stack?: string }, promise: unknown) => void {
23+
return (reason: { stack?: string }, promise: unknown): void => {
24+
client.captureException(reason, {
25+
hint: { originalException: promise },
26+
scope: { extra: { unhandledPromiseRejection: true } },
27+
});
5128
this._handleRejection(client, reason);
5229
};
5330
}

0 commit comments

Comments
 (0)