From b00f196f44088dda5a06302172d8c69cdde8e8ce Mon Sep 17 00:00:00 2001 From: Bae Junehyeon Date: Wed, 29 Apr 2026 02:03:53 +0900 Subject: [PATCH 1/2] feat(storage/s3): make S3 socket timeout configurable The hardcoded socketTimeout: 3000 (introduced in d682bc0 along with stream-based downloads) aborts in-flight R2/S3 GetObject body sockets whenever the response stream is paused for >3s by backpressure from either the client response or the merge upload, surfacing as ECONNRESET on /download/. Expose STORAGE_S3_SOCKET_TIMEOUT_MS so deployments hitting this can raise it without forking. Default raised to 10000 to give backpressure pauses more headroom on first-download proxy paths. --- lib/schemas.ts | 1 + lib/storage.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/schemas.ts b/lib/schemas.ts index b61b3e2..3e1656b 100644 --- a/lib/schemas.ts +++ b/lib/schemas.ts @@ -8,6 +8,7 @@ export const envStorageDriverSchema = type.or( 'AWS_ENDPOINT_URL?': 'string.url', 'AWS_ACCESS_KEY_ID?': 'string', 'AWS_SECRET_ACCESS_KEY?': 'string', + 'STORAGE_S3_SOCKET_TIMEOUT_MS': 'number = 10000', }, { STORAGE_DRIVER: type.unit('filesystem'), diff --git a/lib/storage.ts b/lib/storage.ts index d3c51ee..22a652b 100644 --- a/lib/storage.ts +++ b/lib/storage.ts @@ -527,7 +527,7 @@ class S3Adapter implements StorageAdapter { region: env.AWS_REGION, requestHandler: new NodeHttpHandler({ httpsAgent: agent, - socketTimeout: 3000, + socketTimeout: env.STORAGE_S3_SOCKET_TIMEOUT_MS, }), }) From a3ac36563836543a54227d642b5466ab49f5cd8f Mon Sep 17 00:00:00 2001 From: Bae Junehyeon Date: Tue, 12 May 2026 03:09:11 +0900 Subject: [PATCH 2/2] fix(tests): add STORAGE_S3_SOCKET_TIMEOUT_MS to s3 test env --- tests/setup.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/setup.ts b/tests/setup.ts index 99aa2f0..52d606f 100644 --- a/tests/setup.ts +++ b/tests/setup.ts @@ -77,6 +77,7 @@ const TESTING_ENV_BY_STORAGE_DRIVER = { AWS_ACCESS_KEY_ID: 'minioadmin', AWS_SECRET_ACCESS_KEY: 'minioadmin', AWS_ENDPOINT_URL: 'http://localhost:9000', + STORAGE_S3_SOCKET_TIMEOUT_MS: 10000, }, gcs: { STORAGE_DRIVER: 'gcs',