Skip to content

Commit 623ef49

Browse files
Trotttargos
authored andcommitted
test: address flaky worker test
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]>
1 parent 50ccda2 commit 623ef49

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

test/parallel/test-worker-message-port-transfer-closed.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,9 @@ testSingle(port1, port2);
5050
port2.close(common.mustCall(testBothClosed));
5151
testBothClosed();
5252

53-
setTimeout(common.mustNotCall('The communication channel is still open'),
54-
common.platformTimeout(1000)).unref();
53+
function tickUnref(n, fn) {
54+
if (n === 0) return fn();
55+
setImmediate(tickUnref, n - 1, fn).unref();
56+
}
57+
58+
tickUnref(10, common.mustNotCall('The communication channel is still open'));

0 commit comments

Comments
 (0)