Skip to content

Commit 2865d2a

Browse files
ronagtargos
authored andcommitted
http: unbreak keepAliveTimeoutBuffer
Adds a guard. PR-URL: #59784 Reviewed-By: Gerhard Stöbich <[email protected]> Reviewed-By: Rafael Gonzaga <[email protected]>
1 parent 8671a6c commit 2865d2a

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

lib/_http_server.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,11 +1025,16 @@ function resOnFinish(req, res, socket, state, server) {
10251025
socket.end();
10261026
}
10271027
} else if (state.outgoing.length === 0) {
1028-
if (server.keepAliveTimeout && typeof socket.setTimeout === 'function') {
1028+
const keepAliveTimeout = NumberIsFinite(server.keepAliveTimeout) && server.keepAliveTimeout >= 0 ?
1029+
server.keepAliveTimeout : 0;
1030+
const keepAliveTimeoutBuffer = NumberIsFinite(server.keepAliveTimeoutBuffer) && server.keepAliveTimeoutBuffer >= 0 ?
1031+
server.keepAliveTimeoutBuffer : 1e3;
1032+
1033+
if (keepAliveTimeout && typeof socket.setTimeout === 'function') {
10291034
// Extend the internal timeout by the configured buffer to reduce
10301035
// the likelihood of ECONNRESET errors.
10311036
// This allows fine-tuning beyond the advertised keepAliveTimeout.
1032-
socket.setTimeout(server.keepAliveTimeout + server.keepAliveTimeoutBuffer);
1037+
socket.setTimeout(keepAliveTimeout + keepAliveTimeoutBuffer);
10331038
state.keepAliveTimeoutSet = true;
10341039
}
10351040
} else {

0 commit comments

Comments
 (0)