From 7346130f351c83efe9dd3b54b3c3523b5ea9300e Mon Sep 17 00:00:00 2001 From: Thomas Carmet <8408330+tcarmet@users.noreply.github.com> Date: Tue, 4 Aug 2026 12:03:25 -0700 Subject: [PATCH] CLDSRV-968: Expire idle keep-alive sockets in the functional test client The SDK agents in the aws-node-sdk test client enable keepAlive without an idle timeout, so pooled sockets are never expired client-side. Node's HTTP server closes idle keep-alive connections after 5s and advertises `Keep-Alive: timeout=5`, but the agent only honours that hint when it already has a non-zero timeout of its own. Without one, a burst of requests issued after an idle period can be written to connections the server has already closed, failing with ECONNRESET ("socket hang up"). Set a 4s agent idle timeout so the client retires sockets before the server does. This only destroys sockets sitting in the free pool; in-flight requests stay governed by requestTimeout. --- tests/functional/aws-node-sdk/test/support/config.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/functional/aws-node-sdk/test/support/config.js b/tests/functional/aws-node-sdk/test/support/config.js index 28bc1cc9ba..bda6a2748a 100644 --- a/tests/functional/aws-node-sdk/test/support/config.js +++ b/tests/functional/aws-node-sdk/test/support/config.js @@ -30,6 +30,14 @@ const DEFAULT_GLOBAL_OPTIONS = { // timeout. const REQUEST_TIMEOUT = 30000; +// Idle timeout for pooled keep-alive sockets, kept below the server's 5s +// keep-alive so the client retires a socket before the server closes it. +// A value is required: Node clamps this against the server's advertised +// `Keep-Alive` hint, but only ever downwards from a non-zero timeout +// (`agentTimeout = this.options.timeout || 0`), so leaving it unset means +// pooled sockets never expire. See CLDSRV-968. +const AGENT_IDLE_TIMEOUT = 4000; + const DEFAULT_MEM_OPTIONS = { endpoint: `${transport}://127.0.0.1:8000`, port: 8000, @@ -43,6 +51,7 @@ const DEFAULT_MEM_OPTIONS = { maxSockets: 200, keepAlive: true, keepAliveMsecs: 1000, + timeout: AGENT_IDLE_TIMEOUT, }), }), }; @@ -57,6 +66,7 @@ const DEFAULT_AWS_OPTIONS = { maxSockets: 200, keepAlive: true, keepAliveMsecs: 1000, + timeout: AGENT_IDLE_TIMEOUT, }), }), };