test: do not race server.close with timeout#44039
test: do not race server.close with timeout#44039mmomtchev wants to merge 1 commit intonodejs:mainfrom
Conversation
|
This connection appears to be an idle connection to |
|
Ok it makes sense. It looks like |
| @@ -9,6 +9,6 @@ server.listen(common.mustCall(() => { | |||
| http.get({ port: server.address().port }, common.mustCall((res) => { | |||
| res.on('timeout', common.mustCall(() => req.destroy())); | |||
There was a problem hiding this comment.
| 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.
There was a problem hiding this comment.
Failure will require a timeout and kill from the runner in this case?
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
| setTimeout(common.mustCall(() => server.close()), 2); |
|
Anyway I also think that |
|
About that test, I see timeouts too narrow. I wonder if events get scheduled in the wrong way in the same tick. |
|
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. |
|
@lpinca, there is also libuv/libuv#3686 which is the real reason I am fixing this |
|
@lpinca @ShogunPanda |
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.