From 194cb83f39911b99a4de67dfc72cd9db18a22600 Mon Sep 17 00:00:00 2001 From: Luigi Pinca Date: Thu, 12 Sep 2024 07:47:44 +0200 Subject: [PATCH] test: reduce test-esm-loader-hooks-inspect-wait flakiness Refs: https://github.com/nodejs/node/pull/51560 PR-URL: https://github.com/nodejs/node/pull/54827 Reviewed-By: Chengzhong Wu Reviewed-By: James M Snell --- .../test-esm-loader-hooks-inspect-wait.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/test/parallel/test-esm-loader-hooks-inspect-wait.js b/test/parallel/test-esm-loader-hooks-inspect-wait.js index 249b87b9f1ff8c..cb3ae3d17b9a73 100644 --- a/test/parallel/test-esm-loader-hooks-inspect-wait.js +++ b/test/parallel/test-esm-loader-hooks-inspect-wait.js @@ -10,22 +10,19 @@ const assert = require('assert'); const fixtures = require('../common/fixtures'); const { NodeInstance } = require('../common/inspector-helper.js'); -async function runIfWaitingForDebugger(session) { - const commands = [ - { 'method': 'Runtime.enable' }, - { 'method': 'Debugger.enable' }, - { 'method': 'Runtime.runIfWaitingForDebugger' }, - ]; - - await session.send(commands); -} - async function runTest() { const main = fixtures.path('es-module-loaders', 'register-loader.mjs'); const child = new NodeInstance(['--inspect-wait=0'], '', main); const session = await child.connectInspectorSession(); - await runIfWaitingForDebugger(session); + await session.send({ method: 'NodeRuntime.enable' }); + await session.waitForNotification('NodeRuntime.waitingForDebugger'); + await session.send([ + { 'method': 'Runtime.enable' }, + { 'method': 'Debugger.enable' }, + { 'method': 'Runtime.runIfWaitingForDebugger' }, + ]); + await session.send({ method: 'NodeRuntime.disable' }); await session.waitForDisconnect(); assert.strictEqual((await child.expectShutdown()).exitCode, 0); }