mirror of
https://github.com/zebrajr/node.git
synced 2026-01-15 12:15:26 +00:00
http: unbreak keepAliveTimeoutBuffer
Adds a guard. PR-URL: https://github.com/nodejs/node/pull/59784 Reviewed-By: Gerhard Stöbich <deb2001-github@yahoo.de> Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
This commit is contained in:
@@ -1027,11 +1027,16 @@ function resOnFinish(req, res, socket, state, server) {
|
||||
socket.end();
|
||||
}
|
||||
} else if (state.outgoing.length === 0) {
|
||||
if (server.keepAliveTimeout && typeof socket.setTimeout === 'function') {
|
||||
const keepAliveTimeout = NumberIsFinite(server.keepAliveTimeout) && server.keepAliveTimeout >= 0 ?
|
||||
server.keepAliveTimeout : 0;
|
||||
const keepAliveTimeoutBuffer = NumberIsFinite(server.keepAliveTimeoutBuffer) && server.keepAliveTimeoutBuffer >= 0 ?
|
||||
server.keepAliveTimeoutBuffer : 1e3;
|
||||
|
||||
if (keepAliveTimeout && typeof socket.setTimeout === 'function') {
|
||||
// Extend the internal timeout by the configured buffer to reduce
|
||||
// the likelihood of ECONNRESET errors.
|
||||
// This allows fine-tuning beyond the advertised keepAliveTimeout.
|
||||
socket.setTimeout(server.keepAliveTimeout + server.keepAliveTimeoutBuffer);
|
||||
socket.setTimeout(keepAliveTimeout + keepAliveTimeoutBuffer);
|
||||
state.keepAliveTimeoutSet = true;
|
||||
}
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user