feat(storage/s3): make S3 socket timeout configurable#233
Open
devunt wants to merge 1 commit intofalcondev-oss:devfrom
Open
feat(storage/s3): make S3 socket timeout configurable#233devunt wants to merge 1 commit intofalcondev-oss:devfrom
devunt wants to merge 1 commit intofalcondev-oss:devfrom
Conversation
LouisHaftmann
requested changes
Apr 29, 2026
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.
3a972b0 to
b00f196
Compare
LouisHaftmann
approved these changes
Apr 30, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The S3 client uses a hardcoded
socketTimeout: 3000(ms), introduced in d682bc0 ("perf: reduce memory usage by using node streams") together with stream-based downloads.Because this timeout applies to the GetObject body socket, any pause longer than 3s in
pumpPartsToStreams(lib/storage.ts) — caused by backpressure from either the response stream or the merge upload (mergerStream,partSize: 5MB,queueSize: 1) — aborts the in-flight S3/R2 socket withECONNRESET. The handler has already streamed the headers, so Nitro then surfaces an unhandledH3Error: abortedfollowed byERR_HTTP_HEADERS_SENT.This is reproducible on R2 with non-trivial caches: the very first download of any cache entry always proxies through the server (since
mergedAtis null until the merge finishes), and 3s of stalled read while backpressure resolves is easy to hit.Fix
Expose
STORAGE_S3_SOCKET_TIMEOUT_MSso deployments hitting this can raise the limit without forking. Default raised to10000to give backpressure pauses more headroom on first-download proxy paths.Notes
lib/storage.ts; new env entry inlib/schemas.ts.