@@ -6,7 +6,10 @@ import type { NodeClientOptions } from '../types';
66
77export interface DebugSession {
88 /** 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 ;
1013 /** Gets local variables for an objectId */
1114 getLocalVariables ( objectId : string ) : Promise < Record < string , unknown > > ;
1215}
@@ -32,12 +35,15 @@ class AsyncSession implements DebugSession {
3235 }
3336
3437 /** @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 {
3642 this . _session . connect ( ) ;
3743 this . _session . on ( 'Debugger.paused' , onPause ) ;
3844 this . _session . post ( 'Debugger.enable' ) ;
3945 // 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' } ) ;
4147 }
4248
4349 /** @inheritdoc */
@@ -164,7 +170,14 @@ export interface FrameVariables {
164170
165171/** There are no options yet. This allows them to be added later without breaking changes */
166172// 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+ }
168181
169182/**
170183 * Adds local variables to exception frames
@@ -177,7 +190,7 @@ export class LocalVariables implements Integration {
177190 private readonly _cachedFrames : LRUMap < string , Promise < FrameVariables [ ] > > = new LRUMap ( 20 ) ;
178191
179192 public constructor (
180- _options : Options = { } ,
193+ private readonly _options : Options = { } ,
181194 private readonly _session : DebugSession | undefined = tryNewAsyncSession ( ) ,
182195 ) { }
183196
@@ -194,8 +207,9 @@ export class LocalVariables implements Integration {
194207 clientOptions : NodeClientOptions | undefined ,
195208 ) : void {
196209 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 ,
199213 ) ;
200214
201215 addGlobalEventProcessor ( async event => this . _addLocalVariables ( event ) ) ;
0 commit comments