Skip to content

Commit c1bb439

Browse files
committed
ref(node): Remove raven-node backward-compat code (#4942)
Removes functionality around syncing context from domain.
1 parent 8442065 commit c1bb439

File tree

2 files changed

+8
-39
lines changed

2 files changed

+8
-39
lines changed

packages/node/src/integrations/onunhandledrejection.ts

Lines changed: 8 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -46,36 +46,15 @@ export class OnUnhandledRejection implements Integration {
4646
// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types, @typescript-eslint/no-explicit-any
4747
public sendUnhandledPromise(reason: any, promise: any): void {
4848
const hub = getCurrentHub();
49-
50-
if (!hub.getIntegration(OnUnhandledRejection)) {
51-
this._handleRejection(reason);
52-
return;
53-
}
54-
55-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
56-
const context = (promise.domain && promise.domain.sentryContext) || {};
57-
58-
hub.withScope((scope: Scope) => {
59-
scope.setExtra('unhandledPromiseRejection', true);
60-
61-
// Preserve backwards compatibility with raven-node for now
62-
if (context.user) {
63-
scope.setUser(context.user);
64-
}
65-
if (context.tags) {
66-
scope.setTags(context.tags);
67-
}
68-
if (context.extra) {
69-
scope.setExtras(context.extra);
70-
}
71-
72-
hub.captureException(reason, {
73-
originalException: promise,
74-
data: { mechanism: { handled: false, type: 'onunhandledrejection' } },
49+
if (hub.getIntegration(OnUnhandledRejection)) {
50+
hub.withScope((scope: Scope) => {
51+
scope.setExtra('unhandledPromiseRejection', true);
52+
hub.captureException(reason, {
53+
originalException: promise,
54+
data: { mechanism: { handled: false, type: 'onunhandledrejection' } },
55+
});
7556
});
76-
});
77-
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
78-
57+
}
7958
this._handleRejection(reason);
8059
}
8160

packages/node/test/onunhandledrejection.test.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { Scope } from '@sentry/core';
21
import { Hub } from '@sentry/hub';
32

43
import { OnUnhandledRejection } from '../src/integrations/onunhandledrejection';
@@ -35,21 +34,12 @@ describe('unhandled promises', () => {
3534
};
3635

3736
const captureException = jest.spyOn(Hub.prototype, 'captureException');
38-
const setUser = jest.spyOn(Scope.prototype, 'setUser');
39-
const setExtra = jest.spyOn(Scope.prototype, 'setExtra');
40-
const setExtras = jest.spyOn(Scope.prototype, 'setExtras');
41-
const setTags = jest.spyOn(Scope.prototype, 'setTags');
4237

4338
integration.sendUnhandledPromise('bla', promise);
4439

4540
expect(captureException.mock.calls[0][1]?.data).toEqual({
4641
mechanism: { handled: false, type: 'onunhandledrejection' },
4742
});
4843
expect(captureException.mock.calls[0][0]).toBe('bla');
49-
expect(setUser.mock.calls[0][0]).toEqual({ id: 1 });
50-
expect(setExtra.mock.calls[0]).toEqual(['unhandledPromiseRejection', true]);
51-
52-
expect(setExtras.mock.calls[0]).toEqual([{ extra: '1' }]);
53-
expect(setTags.mock.calls[0]).toEqual([{ tag: '2' }]);
5444
});
5545
});

0 commit comments

Comments
 (0)