Skip to content

Commit 0abd988

Browse files
committed
http: unbreak keepAliveTimeoutBuffer
Adds a guard.
1 parent 2ea31e5 commit 0abd988

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
@@ -1027,11 +1027,16 @@ function resOnFinish(req, res, socket, state, server) {
10271027
socket.end();
10281028
}
10291029
} else if (state.outgoing.length === 0) {
1030-
if (server.keepAliveTimeout && typeof socket.setTimeout === 'function') {
1030+
const keepAliveTimeout = NumberIsFinite(server.keepAliveTimeout) && server.keepAliveTimeout >= 0 ?
1031+
server.keepAliveTimeout : 0;
1032+
const keepAliveTimeoutBuffer = NumberIsFinite(server.keepAliveTimeoutBuffer) && server.keepAliveTimeoutBuffer >= 0 ?
1033+
server.keepAliveTimeoutBuffer : 1e3;
1034+
1035+
if (keepAliveTimeout && typeof socket.setTimeout === 'function') {
10311036
// Extend the internal timeout by the configured buffer to reduce
10321037
// the likelihood of ECONNRESET errors.
10331038
// This allows fine-tuning beyond the advertised keepAliveTimeout.
1034-
socket.setTimeout(server.keepAliveTimeout + server.keepAliveTimeoutBuffer);
1039+
socket.setTimeout(keepAliveTimeout + keepAliveTimeoutBuffer);
10351040
state.keepAliveTimeoutSet = true;
10361041
}
10371042
} else {

0 commit comments

Comments
 (0)