From b00f196f44088dda5a06302172d8c69cdde8e8ce Mon Sep 17 00:00:00 2001 From: Bae Junehyeon Date: Wed, 29 Apr 2026 02:03:53 +0900 Subject: [PATCH] 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, }), })