From 5ab2a5ffdab1d6700505dc43a2d373241ca7f5fe Mon Sep 17 00:00:00 2001 From: jiho Date: Tue, 5 Aug 2025 04:20:19 +0900 Subject: [PATCH] http: add agent.keepAliveTimeoutBuffer option --- doc/api/http.md | 14 ++++++++++ lib/_http_agent.js | 14 +++++++--- ...est-http-agent-keepalive-timeout-buffer.js | 26 +++++++++++++++++++ 3 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 test/parallel/test-http-agent-keepalive-timeout-buffer.js diff --git a/doc/api/http.md b/doc/api/http.md index 8aa2e45c8f1bb7..d8a51f69181bf3 100644 --- a/doc/api/http.md +++ b/doc/api/http.md @@ -414,6 +414,20 @@ changes: An object which contains arrays of sockets currently in use by the agent. Do not modify. +### `agent.keepAliveTimeoutBuffer` + + + +* Type: {number} Timeout in milliseconds. **Default:** `1000` (1 second). + +The buffer time that is subtracted from the server's keep-alive timeout value to reduce the likelihood of +ECONNRESET errors. When a server sends a 'keep-alive' timeout hint in its response headers, +the agent will subtract this buffer value from the hint to determine the actual socket timeout. + +This option only affects sockets that receive a keep-alive timeout hint from the server. + ## Class: `http.ClientRequest`