Skip to content

Commit 27d087c

Browse files
committed
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
1 parent 4899634 commit 27d087c

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

lib/internal/debugger/inspect_probe.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,9 @@ class ProbeInspectorSession {
602602

603603
async handlePaused(params) {
604604
if (this.finished) { return; }
605+
// Keep the initial --inspect-brk pause held until breakpoint setup is
606+
// complete. `Runtime.runIfWaitingForDebugger` releases startup execution.
607+
if (!this.started) { return; }
605608

606609
const hitBreakpoints = params.hitBreakpoints;
607610
if (hitBreakpoints === undefined || hitBreakpoints.length === 0) {
@@ -987,5 +990,6 @@ async function runProbeMode(stdout, probeOptions) {
987990

988991
module.exports = {
989992
parseProbeTokens,
993+
ProbeInspectorSession,
990994
runProbeMode,
991995
};
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// Flags: --expose-internals
2+
// This tests that probe mode keeps the initial --inspect-brk pause held until
3+
// startup has finished binding breakpoints.
4+
'use strict';
5+
6+
const common = require('../common');
7+
common.skipIfInspectorDisabled();
8+
9+
const assert = require('assert');
10+
const { ProbeInspectorSession } = require('internal/debugger/inspect_probe');
11+
12+
const session = new ProbeInspectorSession({
13+
probes: [],
14+
});
15+
16+
const cdpCalls = [];
17+
session.client = {
18+
callMethod: common.mustCall(async (method) => {
19+
cdpCalls.push(method);
20+
}),
21+
};
22+
23+
async function testStartupPauseHandling() {
24+
await session.handlePaused({});
25+
assert.deepStrictEqual(cdpCalls, []);
26+
27+
session.started = true;
28+
await session.handlePaused({});
29+
assert.deepStrictEqual(cdpCalls, ['Debugger.resume']);
30+
}
31+
32+
testStartupPauseHandling().then(common.mustCall());

0 commit comments

Comments
 (0)