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 <anna@addaleax.net>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
  • Loading branch information
Trott committed Jul 24, 2018
1 parent 9453240 commit f93a19b
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 f93a19b

Please sign in to comment.