-
Notifications
You must be signed in to change notification settings - Fork 29.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: address flaky worker test #21893
Conversation
Hm – if I may offer an alternative? diff --git a/test/parallel/test-worker-message-port-transfer-closed.js b/test/parallel/test-worker-message-port-transfer-closed.js
index 435a3789fca7..e3a13bfcbfe9 100644
--- a/test/parallel/test-worker-message-port-transfer-closed.js
+++ b/test/parallel/test-worker-message-port-transfer-closed.js
@@ -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')); This removes the timeout too, but we can keep the test in parallel this way… |
@addaleax SGTM. Do you want to open a PR for that change? Or would you prefer I put it into this one and move it back to parallel here? I'm fine either way, of course. |
@Trott either one is fine :) |
Make test/parallel/test-worker-message-port-transfer-closed.js more reliable by counting ticks rather than using a single setTimeout(). Fixes: nodejs#21892
Updated with @addaleax's suggestion. Re-running stress test to see if this PR passes: https://ci.nodejs.org/job/node-stress-single-test/1970/nodes=freebsd10-64/console Same stress test failing on master: https://ci.nodejs.org/job/node-stress-single-test/1967/nodes=freebsd10-64/console |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😉
Make test/parallel/test-worker-message-port-transfer-closed.js more reliable by counting ticks rather than using a single setTimeout(). Fixes: nodejs#21892 PR-URL: nodejs#21893 Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
Landed in f93a19b |
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]>
Move test/parallel/test-worker-message-port-transfer-closed.js to
sequential to avoid race condition with
setTimeout()
at end of test.Fixes: #21892
/cc @TimothyGu
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes