Skip to content

Commit b0bfcb9

Browse files
trivikraduh95
authored andcommitted
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 PR-URL: #63608 Refs: https://github.com/nodejs/node/actions/runs/26482141780/job/77981519238 Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com>
1 parent 57d060e commit b0bfcb9

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

lib/internal/debugger/inspect_probe.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -624,6 +624,10 @@ class ProbeInspectorSession {
624624

625625
async handlePaused(params) {
626626
if (this.finished) { return; }
627+
// Ignore pauses that arrive before breakpoint setup is complete. Once
628+
// 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; }
627631

628632
const hitBreakpoints = params.hitBreakpoints;
629633
if (hitBreakpoints === undefined || hitBreakpoints.length === 0) {
@@ -1025,5 +1029,6 @@ async function runProbeMode(stdout, probeOptions) {
10251029

10261030
module.exports = {
10271031
parseProbeTokens,
1032+
ProbeInspectorSession,
10281033
runProbeMode,
10291034
};
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 ignores pauses until startup has finished binding
3+
// 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)