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: fix flaky test-net-can-reset-timeout #14257

Closed
wants to merge 1 commit into from

Conversation

Trott
Copy link
Member

@Trott Trott commented Jul 15, 2017

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

test net

@nodejs-github-bot nodejs-github-bot added the test Issues and PRs related to the tests. label Jul 15, 2017
@Trott
Copy link
Member Author

Trott commented Jul 15, 2017

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

@mscdex mscdex added the net Issues and PRs related to the net subsystem. label Jul 15, 2017
@Trott
Copy link
Member Author

Trott commented Jul 15, 2017

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

@Trott
Copy link
Member Author

Trott commented Jul 15, 2017

// Remove this listener so it isn't called again if timeout happens again.
stream.removeListener('timeout', timeoutListener);
});
stream.on('timeout', timeoutListener);
Copy link
Member

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?

Copy link
Contributor

@refack refack left a 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);
Copy link
Contributor

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?

@refack
Copy link
Contributor

refack commented Jul 15, 2017

@Trott I took the liberty of adding a comment with context, feel free to remove it, or whatever.
I approved even with the explicit removeListener... But once seems like the simpler choice...

@Trott Trott force-pushed the fix-can-reset-timer branch from f9936ed to 8ea652d Compare July 16, 2017 00:26
@Trott
Copy link
Member Author

Trott commented Jul 16, 2017

Switched to .once(). Much simpler. 😆

CI: https://ci.nodejs.org/job/node-test-pull-request/9137/

@refack
Copy link
Contributor

refack commented Jul 16, 2017

Switched to .once(). Much simpler. 😆

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

@Trott
Copy link
Member Author

Trott commented Jul 16, 2017

You didn't like my comment or just didn't see it?

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

@Trott Trott force-pushed the fix-can-reset-timer branch from 8ea652d to f9d1804 Compare July 16, 2017 00:59
Trott added a commit to Trott/io.js that referenced this pull request Jul 16, 2017
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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
@Trott
Copy link
Member Author

Trott commented Jul 16, 2017

Landed in 5d3609d

@Trott Trott closed this Jul 16, 2017
@addaleax addaleax mentioned this pull request Jul 18, 2017
addaleax pushed a commit that referenced this pull request Jul 18, 2017
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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
Fishrock123 pushed a commit that referenced this pull request Jul 19, 2017
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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
MylesBorins pushed a commit that referenced this pull request Aug 16, 2017
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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
@MylesBorins MylesBorins mentioned this pull request Aug 16, 2017
MylesBorins pushed a commit that referenced this pull request Aug 16, 2017
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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
MylesBorins pushed a commit that referenced this pull request Sep 5, 2017
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 <refack@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@about-hiroppy.com>
@Trott Trott deleted the fix-can-reset-timer branch January 13, 2022 22:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
net Issues and PRs related to the net subsystem. test Issues and PRs related to the tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

test: flaky test-net-can-reset-timeout
8 participants