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. PR-URL: https://github.com/nodejs/node/pull/28307 Fixes: https://github.com/nodejs/node/issues/28299 Fixes: https://github.com/nodejs/node/issues/28106 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com>
This commit is contained in:
parent
d698983f45
commit
2dec0f9831
@ -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]
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user