@@ -24,35 +24,26 @@ export interface DebugSession {
24
24
* https://nodejs.org/docs/latest-v14.x/api/inspector.html
25
25
*/
26
26
class AsyncSession implements DebugSession {
27
- private _session : Session | undefined = undefined ;
28
-
29
- // eslint-disable-next-line @typescript-eslint/consistent-type-imports
30
- private readonly _inspectorModulePromise : Promise < typeof import ( 'inspector' ) > ;
27
+ private readonly _session : Session ;
31
28
32
29
/** Throws is inspector API is not available */
33
30
public constructor ( ) {
34
31
// Node can be build without inspector support so this can throw
35
- // @ts -ignore eslint-disable-next-line @typescript-eslint/no-var-requires
36
- this . _inspectorModulePromise = import ( 'inspector' ) ;
32
+ // eslint-disable-next-line @typescript-eslint/no-var-requires
33
+ const { Session } = require ( 'inspector' ) ;
34
+ this . _session = new Session ( ) ;
37
35
}
38
36
39
37
/** @inheritdoc */
40
38
public configureAndConnect (
41
39
onPause : ( message : InspectorNotification < Debugger . PausedEventDataType > ) => void ,
42
40
captureAll : boolean ,
43
41
) : void {
44
- this . _inspectorModulePromise
45
- . then ( inspectorModule => {
46
- this . _session = new inspectorModule . Session ( ) ;
47
- this . _session . connect ( ) ;
48
- this . _session . on ( 'Debugger.paused' , onPause ) ;
49
- this . _session . post ( 'Debugger.enable' ) ;
50
- // We only want to pause on uncaught exceptions
51
- this . _session . post ( 'Debugger.setPauseOnExceptions' , { state : captureAll ? 'all' : 'uncaught' } ) ;
52
- } )
53
- . catch ( _ => {
54
- /* ignoring, `inspector` isn't always available */
55
- } ) ;
42
+ this . _session . connect ( ) ;
43
+ this . _session . on ( 'Debugger.paused' , onPause ) ;
44
+ this . _session . post ( 'Debugger.enable' ) ;
45
+ // We only want to pause on uncaught exceptions
46
+ this . _session . post ( 'Debugger.setPauseOnExceptions' , { state : captureAll ? 'all' : 'uncaught' } ) ;
56
47
}
57
48
58
49
/** @inheritdoc */
@@ -78,12 +69,6 @@ class AsyncSession implements DebugSession {
78
69
*/
79
70
private _getProperties ( objectId : string ) : Promise < Runtime . PropertyDescriptor [ ] > {
80
71
return new Promise ( ( resolve , reject ) => {
81
- if ( ! this . _session ) {
82
- // eslint-disable-next-line no-console
83
- console . error ( 'Session is not available' ) ;
84
- reject ( new Error ( 'Session is not available' ) ) ;
85
- return ;
86
- }
87
72
this . _session . post (
88
73
'Runtime.getProperties' ,
89
74
{
@@ -207,7 +192,7 @@ export class LocalVariables implements Integration {
207
192
public constructor (
208
193
private readonly _options : Options = { } ,
209
194
private readonly _session : DebugSession | undefined = tryNewAsyncSession ( ) ,
210
- ) { }
195
+ ) { }
211
196
212
197
/**
213
198
* @inheritDoc
0 commit comments