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: nodejs#21892
  • Loading branch information
Trott committed Jul 23, 2018
1 parent c57e11c commit d6f37e6
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 d6f37e6

Please sign in to comment.