@@ -6,16 +6,18 @@ import {
66import operatorLogPointInstrumentation from '@rxjs-debugging/runtime/out/instrumentation/operatorLogPoint' ;
77import patchObservable from '@rxjs-debugging/runtime/out/instrumentation/operatorLogPoint/patchObservable' ;
88import TelemetryBridge from '@rxjs-debugging/runtime/out/telemetryBridge' ;
9+ import isRxJSImport from '@rxjs-debugging/runtime/out/utils/isRxJSImport' ;
910import waitForCDPBindings from '@rxjs-debugging/runtime/out/utils/waitForCDPBindings' ;
1011import { TelemetryEvent } from '@rxjs-debugging/telemetry' ;
1112import serializeTelemetryEvent from '@rxjs-debugging/telemetry/out/serialize' ;
1213import * as Module from 'module' ;
14+ import type { Subscriber as SubscriberType } from 'rxjs' ;
1315
1416const programPath = process . env [ RUNTIME_PROGRAM_ENV_VAR ] ;
1517const programModule = Module . createRequire ( programPath ) ;
16- const createWrapOperatorFunction = operatorLogPointInstrumentation ( programModule ( 'rxjs' ) . Subscriber ) ;
18+ const Subscriber = getSubscriber ( programModule ) ;
19+ const createWrapOperatorFunction = operatorLogPointInstrumentation ( Subscriber ) ;
1720
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;
1921const originalRequire = Module . prototype . require ;
2022let patchedCache = null ;
2123
@@ -28,7 +30,7 @@ const patchedRequire: NodeJS.Require = function (id) {
2830 this
2931 ) ;
3032
31- if ( observableRegex . exec ( filename ) !== null ) {
33+ if ( isRxJSImport ( filename ) ) {
3234 if ( patchedCache ) {
3335 return patchedCache ;
3436 }
@@ -52,6 +54,18 @@ function defaultSend(event: TelemetryEvent): void {
5254 global [ CDP_BINDING_NAME_SEND_TELEMETRY ] ( message ) ; // global.sendRxJsDebuggerTelemetry will be provided via CDP Runtime.addBinding eventually:
5355}
5456
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+
5569global [ RUNTIME_TELEMETRY_BRIDGE ] = telemetryBridge ;
5670
5771waitForCDPBindings ( 'nodejs' ) ;
0 commit comments