Skip to content
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

Closed
wants to merge 1 commit into from
Closed

test: address flaky worker test #21893

wants to merge 1 commit into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Jul 19, 2018

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), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

@Trott Trott added test Issues and PRs related to the tests. flaky-test Issues and PRs related to the tests with unstable failures on the CI. worker Issues and PRs related to Worker support. labels Jul 19, 2018
@Trott
Copy link
Member Author

Trott commented Jul 19, 2018

@addaleax
Copy link
Member

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…

@Trott
Copy link
Member Author

Trott commented Jul 19, 2018

@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.

@addaleax
Copy link
Member

@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
@Trott
Copy link
Member Author

Trott commented Jul 23, 2018

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

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😉

@Trott
Copy link
Member Author

Trott commented Jul 23, 2018

@Trott
Copy link
Member Author

Trott commented Jul 24, 2018

Trott added a commit to Trott/io.js that referenced this pull request Jul 24, 2018
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]>
@Trott
Copy link
Member Author

Trott commented Jul 24, 2018

Landed in f93a19b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flaky-test Issues and PRs related to the tests with unstable failures on the CI. test Issues and PRs related to the tests. worker Issues and PRs related to Worker support.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate flaky test/parallel/test-worker-message-port-transfer-closed.js
4 participants