Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 441fc92

Browse files
committedJun 19, 2019
test: fix flaky test-worker-debug
Address a race condition in the test; the Worker’s exit events may have been not recorded because the Worker exited before the listeners were attached. Fix the by attaching the event listeners before telling the Worker to exit. Fixes: nodejs#28299 Fixes: nodejs#28106
1 parent 1a4f27a commit 441fc92

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed
 

‎test/parallel/parallel.status

-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ test-worker-memory: PASS,FLAKY
2121
test-http2-client-upload: PASS,FLAKY
2222
# https://github.com/nodejs/node/issues/20750
2323
test-http2-client-upload-reject: PASS,FLAKY
24-
# https://github.com/nodejs/node/issues/28106
25-
test-worker-debug: PASS,FLAKY
2624

2725
[$system==linux]
2826

‎test/parallel/test-worker-debug.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -240,11 +240,17 @@ async function testWaitForDisconnectInWorker(session, post) {
240240
});
241241
await workerSession1.post('Runtime.runIfWaitingForDebugger');
242242

243+
// Create the promises before sending the exit message to the Worker in order
244+
// to avoid race conditions.
245+
const disconnectPromise =
246+
waitForEvent(workerSession1, 'NodeRuntime.waitingForDisconnect');
247+
const executionContextDestroyedPromise =
248+
waitForEvent(workerSession2, 'Runtime.executionContextDestroyed');
243249
worker.postMessage('resume');
244250

245-
await waitForEvent(workerSession1, 'NodeRuntime.waitingForDisconnect');
251+
await disconnectPromise;
246252
post('NodeWorker.detach', { sessionId: sessionId1 });
247-
await waitForEvent(workerSession2, 'Runtime.executionContextDestroyed');
253+
await executionContextDestroyedPromise;
248254

249255
await exitPromise;
250256

0 commit comments

Comments
 (0)
Please sign in to comment.