Skip to content

Commit b00f196

Browse files
committed
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/<id>. 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.
1 parent 16ac265 commit b00f196

2 files changed

Lines changed: 2 additions & 1 deletion

File tree

lib/schemas.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const envStorageDriverSchema = type.or(
88
'AWS_ENDPOINT_URL?': 'string.url',
99
'AWS_ACCESS_KEY_ID?': 'string',
1010
'AWS_SECRET_ACCESS_KEY?': 'string',
11+
'STORAGE_S3_SOCKET_TIMEOUT_MS': 'number = 10000',
1112
},
1213
{
1314
STORAGE_DRIVER: type.unit('filesystem'),

lib/storage.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ class S3Adapter implements StorageAdapter {
527527
region: env.AWS_REGION,
528528
requestHandler: new NodeHttpHandler({
529529
httpsAgent: agent,
530-
socketTimeout: 3000,
530+
socketTimeout: env.STORAGE_S3_SOCKET_TIMEOUT_MS,
531531
}),
532532
})
533533

0 commit comments

Comments
 (0)