11import type { Session } from 'node:inspector/promises' ;
2- import type { Event , EventProcessor , Exception , Hub , Integration , StackFrame , StackParser } from '@sentry/types' ;
2+ import type { Event , EventProcessor , Exception , Hub , Integration , StackParser } from '@sentry/types' ;
33import { LRUMap , logger } from '@sentry/utils' ;
44import type { Debugger , InspectorNotification , Runtime } from 'inspector' ;
55import type { NodeClient } from '../../client' ;
@@ -8,6 +8,13 @@ import type { NodeClientOptions } from '../../types';
88import type { FrameVariables , Options , PausedExceptionEvent , RateLimitIncrement , Variables } from './common' ;
99import { createRateLimiter , functionNamesMatch , hashFrames , hashFromStack } from './common' ;
1010
11+ /**
12+ * When targeting older versions of node, webpack will throw an error if we try to import libraries that are not available
13+ */
14+ function dynamicImport < T > ( module : string ) : Promise < T > {
15+ return import ( module ) ;
16+ }
17+
1118async function unrollArray ( session : Session , objectId : string , name : string , vars : Variables ) : Promise < void > {
1219 const properties : Runtime . GetPropertiesReturnType = await session . post ( 'Runtime.getProperties' , {
1320 objectId,
@@ -95,7 +102,7 @@ export class LocalVariablesAsync implements Integration {
95102 return ;
96103 }
97104
98- import ( 'node:inspector/promises' )
105+ dynamicImport < { Session : typeof Session } > ( 'node:inspector/promises' )
99106 . then ( ( { Session } ) => this . _startDebugger ( new Session ( ) , clientOptions ) )
100107 . catch ( e => logger . error ( 'Failed to load inspector API' , e ) ) ;
101108 }
0 commit comments