Skip to content

Commit 79e9189

Browse files
committed
http: don't set keepAliveTimeoutBuffer twice.
It's already set once through storeHTTPOptions
1 parent 961554c commit 79e9189

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

lib/_http_server.js

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const {
2525
ArrayIsArray,
2626
Error,
2727
MathMin,
28-
NumberIsFinite,
2928
ObjectKeys,
3029
ObjectSetPrototypeOf,
3130
ReflectApply,
@@ -556,12 +555,6 @@ function Server(options, requestListener) {
556555

557556
storeHTTPOptions.call(this, options);
558557

559-
// Optional buffer added to the keep-alive timeout when setting socket timeouts.
560-
// Helps reduce ECONNRESET errors from clients by extending the internal timeout.
561-
// Default is 1000ms if not specified.
562-
const buf = options.keepAliveTimeoutBuffer;
563-
this.keepAliveTimeoutBuffer =
564-
(typeof buf === 'number' && NumberIsFinite(buf) && buf >= 0) ? buf : 1000;
565558
net.Server.call(
566559
this,
567560
{ allowHalfOpen: true, noDelay: options.noDelay ?? true,
@@ -1031,6 +1024,9 @@ function resOnFinish(req, res, socket, state, server) {
10311024
// Extend the internal timeout by the configured buffer to reduce
10321025
// the likelihood of ECONNRESET errors.
10331026
// This allows fine-tuning beyond the advertised keepAliveTimeout.
1027+
validateInteger(server.keepAliveTimeoutBuffer, 'keepAliveTimeoutBuffer', 0);
1028+
validateInteger(server.keepAliveTimeout, 'keepAliveTimeout', 0);
1029+
10341030
socket.setTimeout(server.keepAliveTimeout + server.keepAliveTimeoutBuffer);
10351031
state.keepAliveTimeoutSet = true;
10361032
}

0 commit comments

Comments
 (0)