Repository navigation
fix(storage): forward duplex option for stream uploads via uploadToSignedUrl - #2287
Merged
Merged
Conversation
@supabase/auth-js
@supabase/functions-js
@supabase/postgrest-js
@supabase/realtime-js
@supabase/storage-js
@supabase/supabase-js
commit: |
grdsdev
approved these changes
Apr 27, 2026
ferhatelmas
approved these changes
Apr 27, 2026
This was referenced May 11, 2026
This was referenced May 13, 2026
This was referenced May 13, 2026
This was referenced May 14, 2026
This was referenced May 19, 2026
5 tasks done
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.
Description
Closes the residual stream-handling parity gap in
uploadToSignedUrlleft over from #2275. Without this, uploading aReadableStreamor NodeReadablethrough a signed URL fails on Node 20+ withRequestInit: duplex option is required when sending a body.What changed?
packages/core/storage-js/src/packages/StorageFileApi.ts: in the raw-body branch ofuploadToSignedUrl, mirror the stream detection block fromuploadOrUpdate(StorageFileApi.ts:122-130). When the body is aReadableStreamor a NodeReadable(duck-typed via.pipe), setoptions.duplex = 'half'if the caller did not already supply it. Forwardduplexthrough theputcall so it reachesfetch.packages/core/storage-js/test/storageFileApi.test.ts: two mock-based tests proving (a) auto-detection setsduplex: 'half'for stream-shaped bodies, and (b) a caller-providedduplexis forwarded.packages/core/storage-js/test/storageFileApiNode.test.ts: real-infrastructure test that creates a signed URL and uploadsfs.createReadStreamthrough it, with no explicitduplex, against the Supabase storage Docker server.No new helpers were needed:
FileOptions.duplex(src/lib/types.ts:160-162) andFetchOptions.duplex(src/lib/common/fetch.ts:11-17) already exist, and theputhelper already forwardsduplextofetchvia_getRequestParams(src/lib/common/fetch.ts:114-116).Why was this change needed?
uploadOrUpdatehonors stream bodies;uploadToSignedUrldid not. PR #2275 brought parity formetadata,fileOptions.headers, andcacheControlde-dup on caller FormData, but the stream/duplex case stayed broken. Verified server-side that this is safe:PUT /object/upload/sign/:bucket/*andPOST /object/:bucket/*route through the samefileUploadFromRequest->Uploader.upload()pipeline (uploader.ts:421-568), so raw stream bodies parse identically on both endpoints.Closes #2274 (residual gap), helps close supabase/storage#823.
Screenshots/Examples
Before this change on Node 20+:
After: succeeds and the file lands in storage. Callers can also pass
{ duplex: 'half' }explicitly to override.Breaking changes
The change is additive: the only new behavior is auto-setting
duplex: 'half'when the body is detected as a stream. Existing callers (Blob, FormData, raw string/Buffer/Uint8Array) are unaffected.Checklist
<type>(<scope>): <description>npx nx formatto ensure consistent code formattingAdditional notes
Test results locally:
nx build storage-js: oknx test storage-js(mock unit tests): 12/12uploadToSignedUrltests pass, including the 2 new onesnx test:storage storage-js(full Docker suite, includes the new Node integration test): 388 passed, 2 skipped