From c01f8dfe1701d02357ea3eb6fcdf89e201515ff3 Mon Sep 17 00:00:00 2001 From: Filip Skokan Date: Wed, 14 Oct 2026 11:37:36 +0200 Subject: [PATCH] test: wait for inspector restart before exit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The self-directed debug signal restarts the inspector asynchronously. Wait for the replacement server to listen before asking the child to exit, instead of racing startup against a zero-delay timer. Refs: https://github.com/nodejs/reliability/issues/1687 Signed-off-by: Filip Skokan Assisted-by: Codex PR-URL: https://github.com/nodejs/node/pull/66722 Refs: https://github.com/nodejs/reliability/issues/1686 Refs: https://github.com/nodejs/reliability/issues/1690 Reviewed-By: Antoine du Hamel Reviewed-By: James M Snell Reviewed-By: Matteo Collina Reviewed-By: Guilherme Araújo --- test/parallel/test-inspector-debug-end.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test/parallel/test-inspector-debug-end.js b/test/parallel/test-inspector-debug-end.js index 328f15628e3..fe5a62430fd 100644 --- a/test/parallel/test-inspector-debug-end.js +++ b/test/parallel/test-inspector-debug-end.js @@ -22,18 +22,23 @@ async function testNoSessionNoCrash() { async function testSessionNoCrash() { console.log('Test there\'s no crash stopping server after connecting'); const script = `process._debugEnd(); - process._debugProcess(process.pid); - setTimeout(() => { - console.log("Done"); - process.exit(42); - });`; + process.stdin.once('data', () => { + console.log("Done"); + process.exit(42); + }); + process._debugProcess(process.pid);`; const instance = new NodeInstance('--inspect-brk=0', script); const session = await instance.connectInspectorSession(); await session.send({ method: 'NodeRuntime.enable' }); await session.waitForNotification('NodeRuntime.waitingForDebugger'); + instance.resetPort(); await session.send({ 'method': 'Runtime.runIfWaitingForDebugger' }); await session.waitForServerDisconnect(); + // _debugProcess() starts the inspector asynchronously. Wait for the new + // server to listen before asking the child to exit. + await instance.portPromise; + instance.write('exit'); assert.strictEqual((await instance.expectShutdown()).exitCode, 42); }