1- import { ClientLike , Integration , ScopeContext } from '@sentry/types' ;
1+ import { ClientLike , Integration } from '@sentry/types' ;
22import { consoleSandbox } from '@sentry/utils' ;
33
44import { logAndExitProcess } from './exit' ;
@@ -7,10 +7,6 @@ type UnhandledRejectionMode = 'none' | 'warn' | 'strict';
77type OnUncaughtExceptionOptions = {
88 mode ?: UnhandledRejectionMode ;
99} ;
10- type PromiseRejectionWithDomainContext = {
11- domain ?: { sentryContext ?: ScopeContext } ;
12- } ;
13-
1410const DEFAULT_REJECTION_MODE = 'warn' ;
1511
1612export 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