FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

test: do not race server.close with timeout by mmomtchev · Pull Request #44039 · nodejs/node · GitHub

/ node Public

test: do not race server.close with timeout - #44039

Closed
mmomtchev wants to merge 1 commit into
nodejs:mainfrom
mmomtchev:flaky-test-http-res-timeout
Closed

test: do not race server.close with timeout#44039
mmomtchev wants to merge 1 commit into
nodejs:mainfrom
mmomtchev:flaky-test-http-res-timeout

Conversation

Copy link
Copy Markdown
Contributor

Refs: #43680

This fails when server.close() manages to close the connection before the timeout has fired.
Here is the original issue: #33734
It is not about the behaviour when racing server.close() with the timeout - it is about the timeout not firing at all. I am removing the race condition as I don't think there should be any guarantees on which callback should fire first.

nodejs-github-bot added needs-ci PRs that need a full CI run. test Issues and PRs related to the tests. labels Jul 29, 2022

lpinca commented Jul 29, 2022

Copy link
Copy Markdown
Member

This fails when server.close() manages to close the connection before the timeout has fired

server.close() should not close the connection as the request is in progress, it should only prevent new connections from being accepted, no?

Copy link
Copy Markdown
Contributor Author

This fails when server.close() manages to close the connection before the timeout has fired

server.close() should not close the connection as the request is in progress, it should only prevent new connections from being accepted, no?

This connection appears to be an idle connection to server.close() and so it is closed by Server.prototype.closeIdleConnections. I am not sure if this is expected or a bug.

lpinca commented Jul 30, 2022

Copy link
Copy Markdown
Member

Ok it makes sense. It looks like Server.prototype.close() behavior was changed in #43522. I think there should be at least an option to preserve the old behavior. cc: @ShogunPanda

@@ -9,6 +9,6 @@ server.listen(common.mustCall(() => {
http.get({ port: server.address().port }, common.mustCall((res) => {
res.on('timeout', common.mustCall(() => req.destroy()));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
res.on('timeout', common.mustCall(() => req.destroy()));
res.on('timeout', common.mustCall(() => {
req.destroy();
server.close();
}));

The original issue was that the listener of the 'timeout' event was not called if added on the response object so this should be ok. It does not invalidate the test and only one timer is used.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Failure will require a timeout and kill from the runner in this case?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Failure will require a timeout and kill from the runner in this case?

Yes.

res.on('timeout', common.mustCall(() => req.destroy()));
res.setTimeout(1);
server.close();
setTimeout(common.mustCall(() => server.close()), 2);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
setTimeout(common.mustCall(() => server.close()), 2);

lpinca commented Jul 30, 2022

Copy link
Copy Markdown
Member

Anyway I also think that Server.prototype.closeIdleConnections() incorrectly closes the connection. The client connection is waiting for a response.

Copy link
Copy Markdown
Contributor

@lpinca In #43890 I fixed that behavior. The method will not close connections which are still awaiting a response.

Copy link
Copy Markdown
Contributor

About that test, I see timeouts too narrow. I wonder if events get scheduled in the wrong way in the same tick.

lpinca commented Jul 30, 2022

Copy link
Copy Markdown
Member

FWIW no failures have been registered for this test in last 5 days, so I guess #43890 fixed the underlying issue. I think it is better to keep the test as is if it no longer fails.

Copy link
Copy Markdown
Contributor Author

@lpinca, there is also libuv/libuv#3686 which is the real reason I am fixing this

Copy link
Copy Markdown
Contributor Author

@lpinca @ShogunPanda
In fact #43890 fixed both problems - the flaky unit test and the dependency on the uv event loop behaviour.
I am closing this PR, @danielleadams, you should probably unmark this unit test as being flaky

mmomtchev closed this Jul 30, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-ci PRs that need a full CI run. test Issues and PRs related to the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants


Back | FazBrowse Home | New Git URL