File tree Expand file tree Collapse file tree 3 files changed +19
-11
lines changed Expand file tree Collapse file tree 3 files changed +19
-11
lines changed Original file line number Diff line number Diff line change @@ -465,8 +465,7 @@ export function getCurrentHub(): Hub {
465
465
export function getActiveDomain ( ) : DomainAsCarrier | undefined {
466
466
const sentry = getMainCarrier ( ) . __SENTRY__ ;
467
467
468
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
469
- return sentry && sentry . extensions && sentry . extensions . domain && ( sentry . extensions . domain as any ) . active ;
468
+ return sentry && sentry . extensions && sentry . extensions . domain && sentry . extensions . domain . active ;
470
469
}
471
470
472
471
/**
Original file line number Diff line number Diff line change @@ -21,10 +21,22 @@ export interface Carrier {
21
21
__SENTRY__ ?: {
22
22
hub ?: Hub ;
23
23
/**
24
- * These are extension methods for the hub, the current instance of the hub will be bound to it
24
+ * Extra Hub properties injected by various SDKs
25
25
*/
26
- // eslint-disable-next-line @typescript-eslint/ban-types
27
- extensions ?: { [ key : string ] : Function } ;
26
+ extensions ?: {
27
+ /** Hack to prevent bundlers from breaking our usage of the domain package in the cross-platform Hub package */
28
+ domain ?: typeof domain & {
29
+ /**
30
+ * The currently active domain. This is part of the domain package, but for some reason not declared in the
31
+ * package's typedef.
32
+ */
33
+ active ?: domain . Domain ;
34
+ } ;
35
+ } & {
36
+ /** Extension methods for the hub, which are bound to the current Hub instance */
37
+ // eslint-disable-next-line @typescript-eslint/ban-types
38
+ [ key : string ] : Function ;
39
+ } ;
28
40
} ;
29
41
}
30
42
Original file line number Diff line number Diff line change @@ -57,13 +57,10 @@ const INTEGRATIONS = {
57
57
58
58
export { INTEGRATIONS as Integrations , Transports , Handlers } ;
59
59
60
- // We need to patch domain on the global __SENTRY__ object to make it work for node
61
- // if we don't do this, browser bundlers will have troubles resolving require('domain')
60
+ // We need to patch domain on the global __SENTRY__ object to make it work for node in cross-platform packages like
61
+ // @sentry /hub. If we don't do this, browser bundlers will have troubles resolving ` require('domain')`.
62
62
const carrier = getMainCarrier ( ) ;
63
63
if ( carrier . __SENTRY__ ) {
64
64
carrier . __SENTRY__ . extensions = carrier . __SENTRY__ . extensions || { } ;
65
- if ( ! carrier . __SENTRY__ . extensions . domain ) {
66
- // @ts -ignore domain is missing from extensions Type
67
- carrier . __SENTRY__ . extensions . domain = domain ;
68
- }
65
+ carrier . __SENTRY__ . extensions . domain = carrier . __SENTRY__ . extensions . domain || domain ;
69
66
}
You can’t perform that action at this time.
0 commit comments