@@ -6,16 +6,18 @@ import {
6
6
import operatorLogPointInstrumentation from '@rxjs-debugging/runtime/out/instrumentation/operatorLogPoint' ;
7
7
import patchObservable from '@rxjs-debugging/runtime/out/instrumentation/operatorLogPoint/patchObservable' ;
8
8
import TelemetryBridge from '@rxjs-debugging/runtime/out/telemetryBridge' ;
9
+ import isRxJSImport from '@rxjs-debugging/runtime/out/utils/isRxJSImport' ;
9
10
import waitForCDPBindings from '@rxjs-debugging/runtime/out/utils/waitForCDPBindings' ;
10
11
import { TelemetryEvent } from '@rxjs-debugging/telemetry' ;
11
12
import serializeTelemetryEvent from '@rxjs-debugging/telemetry/out/serialize' ;
12
13
import * as Module from 'module' ;
14
+ import type { Subscriber as SubscriberType } from 'rxjs' ;
13
15
14
16
const programPath = process . env [ RUNTIME_PROGRAM_ENV_VAR ] ;
15
17
const programModule = Module . createRequire ( programPath ) ;
16
- const createWrapOperatorFunction = operatorLogPointInstrumentation ( programModule ( 'rxjs' ) . Subscriber ) ;
18
+ const Subscriber = getSubscriber ( programModule ) ;
19
+ const createWrapOperatorFunction = operatorLogPointInstrumentation ( Subscriber ) ;
17
20
18
- const observableRegex = / r x j s \/ ( _ e s m 5 \/ ) ? i n t e r n a l \/ O b s e r v a b l e / g;
19
21
const originalRequire = Module . prototype . require ;
20
22
let patchedCache = null ;
21
23
@@ -28,7 +30,7 @@ const patchedRequire: NodeJS.Require = function (id) {
28
30
this
29
31
) ;
30
32
31
- if ( observableRegex . exec ( filename ) !== null ) {
33
+ if ( isRxJSImport ( filename ) ) {
32
34
if ( patchedCache ) {
33
35
return patchedCache ;
34
36
}
@@ -52,6 +54,18 @@ function defaultSend(event: TelemetryEvent): void {
52
54
global [ CDP_BINDING_NAME_SEND_TELEMETRY ] ( message ) ; // global.sendRxJsDebuggerTelemetry will be provided via CDP Runtime.addBinding eventually:
53
55
}
54
56
57
+ function getSubscriber (
58
+ customRequire : ( module : string ) => { Subscriber : typeof SubscriberType }
59
+ ) : typeof SubscriberType {
60
+ try {
61
+ // Try access Subscriber via /internal first. This works for RxJS >=7.2.0.
62
+ return customRequire ( 'rxjs/internal/Subscriber' ) . Subscriber ;
63
+ } catch ( _ ) {
64
+ // If the first attempt failed, fall back to a plain root import:
65
+ return customRequire ( 'rxjs' ) . Subscriber ;
66
+ }
67
+ }
68
+
55
69
global [ RUNTIME_TELEMETRY_BRIDGE ] = telemetryBridge ;
56
70
57
71
waitForCDPBindings ( 'nodejs' ) ;
0 commit comments