diff options
author | Owen Smith <owen@omsmith.ca> | 2020-04-28 11:42:34 -0400 |
---|---|---|
committer | Robert Nagy <ronagy@icloud.com> | 2020-04-30 22:42:23 +0200 |
commit | 0413accc6b6e2b81784ab959b400236e4588b123 (patch) | |
tree | d365a5e0bfb4ecd3696318b47242c7cc12cffb0d /lib/_http_agent.js | |
parent | d5e1795f5320567a91da9162558dbd95804803c8 (diff) | |
download | node-new-0413accc6b6e2b81784ab959b400236e4588b123.tar.gz |
http: set default timeout in agent keepSocketAlive
Previous location of setting the timeout would override
behaviour of custom HttpAgents' keepSocketAlive. Moving
it into the default keepSocketAlive allows it to
interoperate with custom agents.
Fixes: https://github.com/nodejs/node/issues/33111
PR-URL: https://github.com/nodejs/node/pull/33127
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com>
Reviewed-By: Andrey Pechkurov <apechkurov@gmail.com>
Diffstat (limited to 'lib/_http_agent.js')
-rw-r--r-- | lib/_http_agent.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/_http_agent.js b/lib/_http_agent.js index 2618c6c3cb..3db42174d7 100644 --- a/lib/_http_agent.js +++ b/lib/_http_agent.js @@ -138,11 +138,6 @@ function Agent(options) { socket._httpMessage = null; this.removeSocket(socket, options); - const agentTimeout = this.options.timeout || 0; - if (socket.timeout !== agentTimeout) { - socket.setTimeout(agentTimeout); - } - socket.once('error', freeSocketErrorListener); freeSockets.push(socket); }); @@ -402,6 +397,11 @@ Agent.prototype.keepSocketAlive = function keepSocketAlive(socket) { socket.setKeepAlive(true, this.keepAliveMsecs); socket.unref(); + const agentTimeout = this.options.timeout || 0; + if (socket.timeout !== agentTimeout) { + socket.setTimeout(agentTimeout); + } + return true; }; |