diff --git a/test/parallel/parallel.status b/test/parallel/parallel.status index 68a685395c43e4..3a70f6f03eb50f 100644 --- a/test/parallel/parallel.status +++ b/test/parallel/parallel.status @@ -21,8 +21,6 @@ test-worker-memory: PASS,FLAKY test-http2-client-upload: PASS,FLAKY # https://github.com/nodejs/node/issues/20750 test-http2-client-upload-reject: PASS,FLAKY -# https://github.com/nodejs/node/issues/28106 -test-worker-debug: PASS,FLAKY [$system==linux] diff --git a/test/parallel/test-worker-debug.js b/test/parallel/test-worker-debug.js index 2629af8cb32e37..1d7bb9bb185e66 100644 --- a/test/parallel/test-worker-debug.js +++ b/test/parallel/test-worker-debug.js @@ -240,11 +240,17 @@ async function testWaitForDisconnectInWorker(session, post) { }); await workerSession1.post('Runtime.runIfWaitingForDebugger'); + // Create the promises before sending the exit message to the Worker in order + // to avoid race conditions. + const disconnectPromise = + waitForEvent(workerSession1, 'NodeRuntime.waitingForDisconnect'); + const executionContextDestroyedPromise = + waitForEvent(workerSession2, 'Runtime.executionContextDestroyed'); worker.postMessage('resume'); - await waitForEvent(workerSession1, 'NodeRuntime.waitingForDisconnect'); + await disconnectPromise; post('NodeWorker.detach', { sessionId: sessionId1 }); - await waitForEvent(workerSession2, 'Runtime.executionContextDestroyed'); + await executionContextDestroyedPromise; await exitPromise;