-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: fix flaky test-net-can-reset-timeout #14257
Conversation
I would like to expedite this so that it doesn't trip us up during Code + Learn later. /cc @nodejs/testing @bengl @joyeecheung @addaleax @refack |
With this change: $ tools/test.py -j 92 --repeat 920 test/parallel/test-net-can-reset-timeout.js
[02:14|% 100|+ 920|- 0]: Done
$ To compare with before the change, see #14241 (comment). |
// Remove this listener so it isn't called again if timeout happens again. | ||
stream.removeListener('timeout', timeoutListener); | ||
}); | ||
stream.on('timeout', timeoutListener); |
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.
Just using .once
instead seems a bit simpler?
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.
1 Nit
// If `active` notices that it was previously removed (perhaps it timed out or | ||
// something) it just does an 'inline append' which re-links the timer. | ||
// Ref: https://github.com/nodejs/node-v0.x-archive/issues/481 | ||
|
||
const net = require('net'); | ||
|
||
const server = net.createServer(common.mustCall(function(stream) { | ||
stream.setTimeout(100); |
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.
What's wrong with once
?
@Trott I took the liberty of adding a comment with context, feel free to remove it, or whatever. |
f9936ed
to
8ea652d
Compare
Switched to |
You didn't like my comment or just didn't see it? // When you write to a socket, it causes 'Timer.active' to be called on it.
// If `active` notices that it was previously removed (perhaps it timed out or
// something) it just does an 'inline append' which re-links the timer.
// Ref: https://github.com/nodejs/node-v0.x-archive/issues/481 |
I wasn't quite sure I understood it out of context. I thought reading the test was actually more clear than the comment, but that may say more about me than the comment? Thinking about it more, though, I think having a link to the issue is a good idea so I'll at least add that back in... |
8ea652d
to
f9d1804
Compare
Use `.once()` rather than `.on()` for timeout listener. Add comment with URL for issue explaining the purpose of the test. (h/t refack) PR-URL: nodejs#14257 Fixes: nodejs#14241 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
Landed in 5d3609d |
Use `.once()` rather than `.on()` for timeout listener. Add comment with URL for issue explaining the purpose of the test. (h/t refack) PR-URL: #14257 Fixes: #14241 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
Use `.once()` rather than `.on()` for timeout listener. Add comment with URL for issue explaining the purpose of the test. (h/t refack) PR-URL: #14257 Fixes: #14241 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
Use `.once()` rather than `.on()` for timeout listener. Add comment with URL for issue explaining the purpose of the test. (h/t refack) PR-URL: #14257 Fixes: #14241 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
Use `.once()` rather than `.on()` for timeout listener. Add comment with URL for issue explaining the purpose of the test. (h/t refack) PR-URL: #14257 Fixes: #14241 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
Use `.once()` rather than `.on()` for timeout listener. Add comment with URL for issue explaining the purpose of the test. (h/t refack) PR-URL: #14257 Fixes: #14241 Reviewed-By: Refael Ackermann <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Yuta Hiroto <[email protected]>
timeout
can fire more than once, so remove the listener after the first time. The test still checks for issue that the test was originally written for (nodejs/node-v0.x-archive#481).Fixes: #14241
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
test net