Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lib/internal/debugger/inspect_probe.js
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,10 @@ class ProbeInspectorSession {

async handlePaused(params) {
if (this.finished) { return; }
// 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;
if (hitBreakpoints === undefined || hitBreakpoints.length === 0) {
Expand Down Expand Up @@ -1025,5 +1029,6 @@ async function runProbeMode(stdout, probeOptions) {

module.exports = {
parseProbeTokens,
ProbeInspectorSession,
runProbeMode,
};
32 changes: 32 additions & 0 deletions test/parallel/test-debugger-probe-startup-pause.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// Flags: --expose-internals
// This tests that probe mode ignores pauses 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());
Loading