Skip to content
Open
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
4 changes: 4 additions & 0 deletions lib/internal/debugger/inspect_probe.js
Original file line number Diff line number Diff line change
Expand Up @@ -599,6 +599,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) {
Expand Down Expand Up @@ -979,5 +982,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 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());
Loading