@@ -6,7 +6,10 @@ import type { NodeClientOptions } from '../types';
6
6
7
7
export interface DebugSession {
8
8
/** Configures and connects to the debug session */
9
- configureAndConnect ( onPause : ( message : InspectorNotification < Debugger . PausedEventDataType > ) => void ) : void ;
9
+ configureAndConnect (
10
+ onPause : ( message : InspectorNotification < Debugger . PausedEventDataType > ) => void ,
11
+ captureAll : boolean ,
12
+ ) : void ;
10
13
/** Gets local variables for an objectId */
11
14
getLocalVariables ( objectId : string ) : Promise < Record < string , unknown > > ;
12
15
}
@@ -32,12 +35,15 @@ class AsyncSession implements DebugSession {
32
35
}
33
36
34
37
/** @inheritdoc */
35
- public configureAndConnect ( onPause : ( message : InspectorNotification < Debugger . PausedEventDataType > ) => void ) : void {
38
+ public configureAndConnect (
39
+ onPause : ( message : InspectorNotification < Debugger . PausedEventDataType > ) => void ,
40
+ captureAll : boolean ,
41
+ ) : void {
36
42
this . _session . connect ( ) ;
37
43
this . _session . on ( 'Debugger.paused' , onPause ) ;
38
44
this . _session . post ( 'Debugger.enable' ) ;
39
45
// We only want to pause on uncaught exceptions
40
- this . _session . post ( 'Debugger.setPauseOnExceptions' , { state : 'uncaught' } ) ;
46
+ this . _session . post ( 'Debugger.setPauseOnExceptions' , { state : captureAll ? 'all' : 'uncaught' } ) ;
41
47
}
42
48
43
49
/** @inheritdoc */
@@ -164,7 +170,14 @@ export interface FrameVariables {
164
170
165
171
/** There are no options yet. This allows them to be added later without breaking changes */
166
172
// eslint-disable-next-line @typescript-eslint/no-empty-interface
167
- interface Options { }
173
+ interface Options {
174
+ /**
175
+ * Capture local variables for both handled and unhandled exceptions
176
+ *
177
+ * Default: false - Only captures local variables for uncaught exceptions
178
+ */
179
+ captureAllExceptions ?: boolean ;
180
+ }
168
181
169
182
/**
170
183
* Adds local variables to exception frames
@@ -177,7 +190,7 @@ export class LocalVariables implements Integration {
177
190
private readonly _cachedFrames : LRUMap < string , Promise < FrameVariables [ ] > > = new LRUMap ( 20 ) ;
178
191
179
192
public constructor (
180
- _options : Options = { } ,
193
+ private readonly _options : Options = { } ,
181
194
private readonly _session : DebugSession | undefined = tryNewAsyncSession ( ) ,
182
195
) { }
183
196
@@ -194,8 +207,9 @@ export class LocalVariables implements Integration {
194
207
clientOptions : NodeClientOptions | undefined ,
195
208
) : void {
196
209
if ( this . _session && clientOptions ?. includeLocalVariables ) {
197
- this . _session . configureAndConnect ( ev =>
198
- this . _handlePaused ( clientOptions . stackParser , ev as InspectorNotification < PausedExceptionEvent > ) ,
210
+ this . _session . configureAndConnect (
211
+ ev => this . _handlePaused ( clientOptions . stackParser , ev as InspectorNotification < PausedExceptionEvent > ) ,
212
+ ! ! this . _options . captureAllExceptions ,
199
213
) ;
200
214
201
215
addGlobalEventProcessor ( async event => this . _addLocalVariables ( event ) ) ;
0 commit comments