Commit Graph

8 Commits

Author SHA1 Message Date
Robert Nagy
8700d89306 http: fix socket re-use races
Whether and when a socket is destroyed or not after a timeout is up to
the user. This leaves an edge case where a socket that has emitted
'timeout' might be re-used from the free pool. Even if destroy is called
on the socket, it won't be removed from the freelist until 'close' which
can happen several ticks later.

Sockets are removed from the free list on the 'close' event.
However, there is a delay between calling destroy() and 'close'
being emitted. This means that it possible for a socket that has
been destroyed to be re-used from the free list, causing unexpected
failures.

PR-URL: https://github.com/nodejs/node/pull/32000
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Denys Otrishko <shishugi@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2020-03-07 20:51:12 +01:00
Luigi Pinca
b361f9577f test: refactor two http client timeout tests
Refactor test-http-client-set-timeout and
test-http-client-timeout-option-with-agent.

PR-URL: https://github.com/nodejs/node/pull/25473
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-02-12 08:01:26 +01:00
Rich Trott
b8977045f2 test: refactor test-http-client-timeout-option-with-agent
* Switch from Date.now() to process.hrtime.bigint().
* Move start time recording to before the request is created, not after.

Fixes: https://github.com/nodejs/node/issues/25746

PR-URL: https://github.com/nodejs/node/pull/25752
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: James M Snell <jasnell@gmail.com>
2019-01-29 18:36:04 -08:00
potham
f25123822e test: replace callback functions with arrow functions
PR-URL: https://github.com/nodejs/node/pull/24432
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Gireesh Punathil <gpunathi@in.ibm.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
2018-11-17 21:07:52 -08:00
Rich Trott
36696cfe84 test: improve assert message in http timeout test
PR-URL: https://github.com/nodejs/node/pull/22403
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-08-20 18:59:12 -07:00
Rich Trott
4b71b01339 test: move http timeout test to parallel
test-http-client-timeout-option-with-agent no longer checks that the
timeout happens within a certain tolerance so it can be moved to the
parallel test suite.

PR-URL: https://github.com/nodejs/node/pull/22403
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
2018-08-20 18:59:08 -07:00
Ouyang Yadong
f8fda89df1
test: move test-http-client-timeout-option-with-agent to sequential
The timeout event cannot be precisely timed and the actual timeout
may be longer in some situations. Here we move this test into the
sequential folder to make it happens less likely.

PR-URL: https://github.com/nodejs/node/pull/22083
Fixes: https://github.com/nodejs/node/issues/22041
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: George Adams <george.adams@uk.ibm.com>
2018-08-13 13:12:21 +01:00
killagu
949e885148
http: fix request with option timeout and agent
When request with both timeout and agent, timeout not
work. This patch will fix it, socket timeout will set
to request timeout before socket is connected, and
socket timeout will reset to agent timeout after
response end.

Fixes: https://github.com/nodejs/node/issues/21185

PR-URL: https://github.com/nodejs/node/pull/21204
Reviewed-By: Khaidi Chu <i@2333.moe>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Ujjwal Sharma <usharma1998@gmail.com>
2018-07-13 18:44:03 +02:00