@@ -474,6 +474,8 @@ class ProbeInspectorSession {
474474 this . inFlight = null ;
475475 // Most recently completed probe, used for `error.probe` when a non-evaluate CDP call rejects.
476476 this . lastProbeIndex = null ;
477+ this . deferredStartupPause = null ;
478+ this . handledPauseAfterStart = false ;
477479 const { promise, resolve } = PromiseWithResolvers ( ) ;
478480 this . completionPromise = promise ;
479481 this . resolveCompletion = resolve ;
@@ -624,10 +626,17 @@ class ProbeInspectorSession {
624626
625627 async handlePaused ( params ) {
626628 if ( this . finished ) { return ; }
627- // Ignore pauses that arrive before breakpoint setup is complete. Once
629+ // Defer pauses that arrive before breakpoint setup is complete. Once
628630 // startup is marked complete, `Runtime.runIfWaitingForDebugger` may surface
629- // the initial --inspect-brk pause, which the normal resume path handles.
630- if ( ! this . started ) { return ; }
631+ // the initial --inspect-brk pause, which the normal resume path handles. If
632+ // it was already surfaced while binding breakpoints, replay it after startup
633+ // so the target is not left paused forever.
634+ if ( ! this . started ) {
635+ this . deferredStartupPause = params ;
636+ return ;
637+ }
638+
639+ this . handledPauseAfterStart = true ;
631640
632641 const hitBreakpoints = params . hitBreakpoints ;
633642 if ( hitBreakpoints === undefined || hitBreakpoints . length === 0 ) {
@@ -676,6 +685,16 @@ class ProbeInspectorSession {
676685 await this . resume ( ) ;
677686 }
678687
688+ async handleDeferredStartupPause ( ) {
689+ if ( this . deferredStartupPause === null || this . handledPauseAfterStart ) {
690+ return ;
691+ }
692+
693+ const params = this . deferredStartupPause ;
694+ this . deferredStartupPause = null ;
695+ await this . handlePaused ( params ) ;
696+ }
697+
679698 async evaluateProbe ( callFrameId , probeIndex , location ) {
680699 if ( this . finished ) { return ; }
681700 const probe = this . probes [ probeIndex ] ;
@@ -998,6 +1017,7 @@ class ProbeInspectorSession {
9981017 this . started = true ;
9991018 this . startTimeout ( ) ;
10001019 await this . callCdp ( 'Runtime.runIfWaitingForDebugger' ) ;
1020+ await this . handleDeferredStartupPause ( ) ;
10011021 } catch ( err ) {
10021022 if ( err !== kInspectorFailedSentinel ) { throw err ; }
10031023 }
0 commit comments