Repository navigation
fix(upload): send Storage uploads with fetch in the standalone binary - #359
Merged
Merged
Conversation
The standalone binary runs on Bun. tus-js-client's default Node HTTP stack pipes each chunk into a node:http request, and under Bun the upload-creating POST fails with "The socket connection was closed unexpectedly". So every binary uploaded from the standalone CLI was stored without its Storage copy. The B2 upload still succeeded, so the command exited 0 and only --debug showed the error. Under Bun, tus now uses a small fetch-based HTTP stack that reads each chunk into memory (one chunk, 6 MB, at a time) and sends it with fetch. Node keeps tus's default stack unchanged. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. 🤖 Generated with Claude Code |
Merged
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 standalone
dcdbinary (built withbun build --compile) could not upload to Supabase Storage. tus-js-client's default Node HTTP stack pipes each chunk into anode:httprequest. Under Bun, the first request (the POST that creates the upload, sent with the first 6 MB chunk) fails with:The B2 upload still succeeded, so the command exited 0. The binary was stored without its Storage copy, and only
--debugshowed the error. The npm package, which runs on Node, was not affected.Fix
src/gateways/fetch-http-stack.ts: a small tusHttpStackthat reads each chunk into memory and sends it withfetch. tus sends one chunk per request, so this holds at most one 6 MB chunk at a time.fetchcan't report upload progress, so progress moves once per chunk.SupabaseGateway.uploadResumableuses it only under Bun. Under Node, tus keeps its default stack, unchanged.tusHttpStackOptions()returns{}under Node, not{ httpStack: undefined }. tus spreads options over its defaults, so an explicitundefinedwould remove the default stack.Testing
bun build --compileand randcd upload --debugagainst the dev API:Backblaze: ✓, Supabase: ✓, and the stored binary has its Storage path.FetchHttpStackagainst a local tus server (data on create, then PATCHes), error handling, and the Bun/Node option choice.pnpm lint,pnpm typecheck,pnpm test:unit(769 passing).Tested on darwin-arm64 only. Linux and Windows binaries use the same code path.
🤖 Generated with Claude Code