Skip to content

Commit 5fce091

Browse files
committed
http: unbreak keepAliveTimeoutBuffer
If keepAliveTimeoutBuffer is set to undefined (for whatever reason) or if not set at all we will throw. This adds a guard.
1 parent 2ea31e5 commit 5fce091

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/_http_server.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1027,11 +1027,17 @@ 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+
1040+
socket.setTimeout(keepAliveTimeout + keepAliveTimeoutBuffer);
10351041
state.keepAliveTimeoutSet = true;
10361042
}
10371043
} else {

0 commit comments

Comments
 (0)