Skip to content

Commit

Permalink
test: address flaky worker test
Browse files Browse the repository at this point in the history
Make test/parallel/test-worker-message-port-transfer-closed.js more
reliable by counting ticks rather than using a single setTimeout().

Fixes: #21892

PR-URL: #21893
Reviewed-By: Anna Henningsen <[email protected]>
Reviewed-By: Yuta Hiroto <[email protected]>
  • Loading branch information
Trott authored and targos committed Jul 26, 2018
1 parent 50ccda2 commit 623ef49
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions test/parallel/test-worker-message-port-transfer-closed.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,9 @@ testSingle(port1, port2);
port2.close(common.mustCall(testBothClosed));
testBothClosed();

setTimeout(common.mustNotCall('The communication channel is still open'),
common.platformTimeout(1000)).unref();
function tickUnref(n, fn) {
if (n === 0) return fn();
setImmediate(tickUnref, n - 1, fn).unref();
}

tickUnref(10, common.mustNotCall('The communication channel is still open'));

0 comments on commit 623ef49

Please sign in to comment.