@@ -707,7 +707,8 @@ class ProbeInspectorSession {
707707
708708 async callCdp ( method , params , probe = null ) {
709709 if ( this . finished ) { throw kInspectorFailedSentinel ; }
710- this . inFlight = { __proto__ : null , method, probe } ;
710+ const inFlight = { __proto__ : null , method, probe } ;
711+ this . inFlight = inFlight ;
711712 debug ( 'CDP -> %s%s' , method , probe !== null ? `, probe=${ probe . index } ` : '' ) ;
712713 try {
713714 const result = await this . client . callMethod ( method , params ) ;
@@ -730,6 +731,7 @@ class ProbeInspectorSession {
730731 this . recordInspectorFailure ( {
731732 reason : 'Target process exited during probe evaluation' ,
732733 advice : kReviewProbeExprAdvice ,
734+ inFlight,
733735 } ) ;
734736 }
735737 throw kInspectorFailedSentinel ;
@@ -741,49 +743,55 @@ class ProbeInspectorSession {
741743 reason : 'Probe mode failed before user code ran' ,
742744 advice : kStartupTeardownAdvice ,
743745 cdpError : err ,
746+ inFlight,
744747 } ) ;
745748 } else if ( method === 'Debugger.evaluateOnCallFrame' ) {
746749 this . recordInspectorFailure ( {
747750 reason : 'The inspector could not evaluate a probe expression' ,
748751 advice : `The rejection details are recorded on the probe hit. ${ kReviewProbeExprAdvice } ` ,
749752 cdpError : err ,
753+ inFlight,
750754 } ) ;
751755 } else if ( this . lastProbeIndex !== null ) {
752756 this . recordInspectorFailure ( {
753757 reason : 'Probe session failed after a probe evaluation' ,
754758 advice : 'If the failure repeats, review the most-recently-evaluated probe expression.' ,
755759 cdpError : err ,
760+ inFlight,
756761 } ) ;
757762 } else {
758763 this . recordInspectorFailure ( {
759764 reason : 'Probe session failed during inspector activity' ,
760765 advice : 'This is likely a Node.js bug. Please file an issue.' ,
761766 cdpError : err ,
767+ inFlight,
762768 } ) ;
763769 }
764770 throw kInspectorFailedSentinel ;
765771 } finally {
766- this . inFlight = null ;
772+ if ( this . inFlight === inFlight ) {
773+ this . inFlight = null ;
774+ }
767775 }
768776 }
769777
770778 // Records the first inspector-side terminal for the session, later callers are ignored.
771- recordInspectorFailure ( { reason, advice, cdpError, internalError } ) {
779+ recordInspectorFailure ( { reason, advice, cdpError, internalError, inFlight = this . inFlight } ) {
772780 if ( this . finished ) { return ; }
773781 debug ( 'recordInspectorFailure "%s": inFlight=%j, lastProbeIndex=%s, cdpError=%j' ,
774- reason , this . inFlight , this . lastProbeIndex , cdpError ) ;
782+ reason , inFlight , this . lastProbeIndex , cdpError ) ;
775783 const child = this . child ;
776784 const exitedAbnormally = child !== null &&
777785 ( child . signalCode !== null || ( child . exitCode !== null && child . exitCode !== 0 ) ) ;
778- const inFlightProbe = this . inFlight === null ? null : this . inFlight . probe ;
786+ const inFlightProbe = inFlight === null ? null : inFlight . probe ;
779787 // This normally emits `probe_failure`, but yields to `probe_target_exit` when the child
780788 // has already exited abnormally and there is no in-flight probe to attribute to.
781789 if ( exitedAbnormally && inFlightProbe === null ) {
782790 this . finishWithTrustedResult ( this . getProbeTargetExitEvent ( child . exitCode , child . signalCode ) ) ;
783791 return ;
784792 }
785793
786- const failedCdpMethod = this . inFlight === null ? null : this . inFlight . method ;
794+ const failedCdpMethod = inFlight === null ? null : inFlight . method ;
787795 let protocolError = null ;
788796 // // `ERR_DEBUGGER_ERROR` is a Node-internal code, not a CDP-level protocol code
789797 if ( cdpError !== undefined && cdpError . code !== 'ERR_DEBUGGER_ERROR' ) {
0 commit comments