-
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
Investigate flaky test test-http-client-timeout-event #2555
Comments
There seems to be a race condition between timers. I'll try to send in a PR in the coming week. |
Possible solution might be to use |
@Trott good tip, thanks. I ended up doing the platform timeout for part of it, but refractored some of it to allow for ending early and reducing racy-ness. Here's the diff if you want it, I'll submit the PR once I get access to a pi to double check: diff --git a/test/parallel/test-http-client-timeout-event.js b/test/parallel/test-http-client-timeout-event.js
index c9d6594..77776eb 100644
--- a/test/parallel/test-http-client-timeout-event.js
+++ b/test/parallel/test-http-client-timeout-event.js
@@ -25,16 +25,24 @@ server.listen(options.port, options.host, function() {
server.close();
});
- var timeout_events = 0;
req.setTimeout(1);
- req.on('timeout', function() {
- timeout_events += 1;
- });
- setTimeout(function() {
+ req.on('timeout', common.mustCall(function() {
+ clearTimeout(timer);
+
req.destroy();
- assert.equal(timeout_events, 1);
- }, 100);
- setTimeout(function() {
- req.end();
- }, 50);
+ }, 1));
+
+ // Emit the request immediately, and once the request is given a socket,
+ // ensure that the timeout has been emitted after ~100ms. If the timeout
+ // is called before that, the test will exit early.
+ req.end();
+
+ var timer;
+ req.on('socket', function() {
+ // If the timer is called, then the timeout is either taking an
+ // extraordinarily long time, or it won't fire.
+ timer = setTimeout(function() {
+ throw new Error('timeout was not called');
+ }, common.platformTimeout(100));
+ });
}); |
I wasn't able to see any flakiness before or after on a raspberry pi after 1000 runs each, so the PR may just be in the blind. cc @rvagg I'm done with the machine, thanks! |
@brendanashworth Stress test on current master shows that this test is still flaky: https://ci.nodejs.org/job/node-stress-single-test/24/nodes=pi1-raspbian-wheezy/console Fails with:
If you've got a publicly available branch on GitHub with your proposed solution, we can run that through the stress test and see if it fails or not. |
Just subbing in @brendanashworth I'll submit a PR with just the |
Use common.platformTimeout() to make test more reliable on Raspberry Pi. Fixes: nodejs#2555
Examples of failures:
pi1-raspbian-wheezy
The text was updated successfully, but these errors were encountered: