From 60341848ea436e3f1ddeefa34b4a6566f6715b25 Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Wed, 27 May 2026 23:51:23 -0700 Subject: [PATCH 1/2] debugger: defer probe pause handling until startup Keep the initial --inspect-brk pause held until probe breakpoints are bound and probe mode explicitly releases the target. This prevents the generic pause handler from resuming user code before probes are ready. Refs: https://github.com/nodejs/node/actions/runs/26482141780/job/77981519238 Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: openai:gpt-5.5 --- lib/internal/debugger/inspect_probe.js | 4 +++ .../test-debugger-probe-startup-pause.js | 32 +++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 test/parallel/test-debugger-probe-startup-pause.js diff --git a/lib/internal/debugger/inspect_probe.js b/lib/internal/debugger/inspect_probe.js index c7c2d4627e4ae2..0cdeb3b6c4bab1 100644 --- a/lib/internal/debugger/inspect_probe.js +++ b/lib/internal/debugger/inspect_probe.js @@ -624,6 +624,9 @@ class ProbeInspectorSession { async handlePaused(params) { if (this.finished) { return; } + // Keep the initial --inspect-brk pause held until breakpoint setup is + // complete. `Runtime.runIfWaitingForDebugger` releases startup execution. + if (!this.started) { return; } const hitBreakpoints = params.hitBreakpoints; if (hitBreakpoints === undefined || hitBreakpoints.length === 0) { @@ -1025,5 +1028,6 @@ async function runProbeMode(stdout, probeOptions) { module.exports = { parseProbeTokens, + ProbeInspectorSession, runProbeMode, }; diff --git a/test/parallel/test-debugger-probe-startup-pause.js b/test/parallel/test-debugger-probe-startup-pause.js new file mode 100644 index 00000000000000..0cd9c5b18a4881 --- /dev/null +++ b/test/parallel/test-debugger-probe-startup-pause.js @@ -0,0 +1,32 @@ +// Flags: --expose-internals +// This tests that probe mode keeps the initial --inspect-brk pause held until +// startup has finished binding breakpoints. +'use strict'; + +const common = require('../common'); +common.skipIfInspectorDisabled(); + +const assert = require('assert'); +const { ProbeInspectorSession } = require('internal/debugger/inspect_probe'); + +const session = new ProbeInspectorSession({ + probes: [], +}); + +const cdpCalls = []; +session.client = { + callMethod: common.mustCall(async (method) => { + cdpCalls.push(method); + }), +}; + +async function testStartupPauseHandling() { + await session.handlePaused({}); + assert.deepStrictEqual(cdpCalls, []); + + session.started = true; + await session.handlePaused({}); + assert.deepStrictEqual(cdpCalls, ['Debugger.resume']); +} + +testStartupPauseHandling().then(common.mustCall()); From ff60ee7c8030c744dc3b0266b93966e2a6f741da Mon Sep 17 00:00:00 2001 From: "Kamat, Trivikram" <16024985+trivikr@users.noreply.github.com> Date: Mon, 15 Jun 2026 07:11:37 -0700 Subject: [PATCH 2/2] debugger: clarify inspect probe startup pause ordering --- lib/internal/debugger/inspect_probe.js | 5 +++-- test/parallel/test-debugger-probe-startup-pause.js | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/internal/debugger/inspect_probe.js b/lib/internal/debugger/inspect_probe.js index 0cdeb3b6c4bab1..e7abc2e48cd365 100644 --- a/lib/internal/debugger/inspect_probe.js +++ b/lib/internal/debugger/inspect_probe.js @@ -624,8 +624,9 @@ class ProbeInspectorSession { async handlePaused(params) { if (this.finished) { return; } - // Keep the initial --inspect-brk pause held until breakpoint setup is - // complete. `Runtime.runIfWaitingForDebugger` releases startup execution. + // Ignore pauses that arrive before breakpoint setup is complete. Once + // startup is marked complete, `Runtime.runIfWaitingForDebugger` may surface + // the initial --inspect-brk pause, which the normal resume path handles. if (!this.started) { return; } const hitBreakpoints = params.hitBreakpoints; diff --git a/test/parallel/test-debugger-probe-startup-pause.js b/test/parallel/test-debugger-probe-startup-pause.js index 0cd9c5b18a4881..917026bf13fe0f 100644 --- a/test/parallel/test-debugger-probe-startup-pause.js +++ b/test/parallel/test-debugger-probe-startup-pause.js @@ -1,6 +1,6 @@ // Flags: --expose-internals -// This tests that probe mode keeps the initial --inspect-brk pause held until -// startup has finished binding breakpoints. +// This tests that probe mode ignores pauses until startup has finished binding +// breakpoints. 'use strict'; const common = require('../common');