http: add server.keepAliveTimeoutBuffer option

PR-URL: https://github.com/nodejs/node/pull/59243
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Jason Zhang <xzha4350@gmail.com>
This commit is contained in:
Haram Jeong 2025-08-04 22:47:09 +09:00 committed by GitHub
parent 5bea645e4b
commit f7c2a7ed4a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 83 additions and 8 deletions

View file

@ -1942,18 +1942,39 @@ added: v8.0.0
The number of milliseconds of inactivity a server needs to wait for additional
incoming data, after it has finished writing the last response, before a socket
will be destroyed. If the server receives new data before the keep-alive
timeout has fired, it will reset the regular inactivity timeout, i.e.,
[`server.timeout`][].
will be destroyed.
This timeout value is combined with the
\[`server.keepAliveTimeoutBuffer`]\[] option to determine the actual socket
timeout, calculated as:
socketTimeout = keepAliveTimeout + keepAliveTimeoutBuffer
If the server receives new data before the keep-alive timeout has fired, it
will reset the regular inactivity timeout, i.e., [`server.timeout`][].
A value of `0` will disable the keep-alive timeout behavior on incoming
connections.
A value of `0` makes the http server behave similarly to Node.js versions prior
A value of `0` makes the HTTP server behave similarly to Node.js versions prior
to 8.0.0, which did not have a keep-alive timeout.
The socket timeout logic is set up on connection, so changing this value only
affects new connections to the server, not any existing connections.
### `server.keepAliveTimeoutBuffer`
<!-- YAML
added: REPLACEME
-->
* Type: {number} Timeout in milliseconds. **Default:** `1000` (1 second).
An additional buffer time added to the
[`server.keepAliveTimeout`][] to extend the internal socket timeout.
This buffer helps reduce connection reset (`ECONNRESET`) errors by increasing
the socket timeout slightly beyond the advertised keep-alive timeout.
This option applies only to new incoming connections.
### `server[Symbol.asyncDispose]()`
<!-- YAML