diff --git a/lib/internal/debugger/inspect_probe.js b/lib/internal/debugger/inspect_probe.js index e7abc2e48cd365..339904b6556882 100644 --- a/lib/internal/debugger/inspect_probe.js +++ b/lib/internal/debugger/inspect_probe.js @@ -707,7 +707,8 @@ class ProbeInspectorSession { async callCdp(method, params, probe = null) { if (this.finished) { throw kInspectorFailedSentinel; } - this.inFlight = { __proto__: null, method, probe }; + const request = { __proto__: null, method, probe }; + this.inFlight = request; debug('CDP -> %s%s', method, probe !== null ? `, probe=${probe.index}` : ''); try { const result = await this.client.callMethod(method, params); @@ -763,7 +764,9 @@ class ProbeInspectorSession { } throw kInspectorFailedSentinel; } finally { - this.inFlight = null; + if (this.inFlight === request) { + this.inFlight = null; + } } } diff --git a/test/parallel/test-debugger-probe-failure-process-exit.js b/test/parallel/test-debugger-probe-failure-process-exit.js index f7c9d4abc92e5a..89952d2023ee57 100644 --- a/test/parallel/test-debugger-probe-failure-process-exit.js +++ b/test/parallel/test-debugger-probe-failure-process-exit.js @@ -1,5 +1,6 @@ -// This tests that a clean process.exit(0) from inside a probe expression -// surfaces as probe_failure, not probe_target_exit. +// This tests end-to-end that a clean process.exit(0) from inside a probe +// expression remains attributed to that probe and surfaces as probe_failure, +// not probe_target_exit. 'use strict'; const common = require('../common');