Skip to content

fix(storage): harden resumable upload failure, cancel and record handling - #1985

Merged
spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-2276-resumable-upload-review-fixes
Oct 19, 2026
Merged

spydon merged 1 commit into
mainfrom
lukasklingsbo/sdk-2276-resumable-upload-review-fixes

Conversation

@spydon

@spydon spydon commented Oct 19, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #1984 (SDK-2276) with fixes from a review of the resumable upload code. #1984 was merged before these commits were pushed.

Fixes

  • A failed upload keeps its handle. Once its retries run out, an upload that still has a record stays registered as live. resumeUpload(id, file) now returns that same ResumableUpload and resumes it, as documented. Before, it built a second handle, and the two could send PATCH requests to one upload URL at the same time.
  • A failing record store no longer hangs an upload. If removing the record throws inside the failure handler, the error is logged at warning level. Before, _run threw: done never completed, the status stayed uploading, and every later resume() was silently skipped.
  • Cancel loses to a completed upload. cancel() now waits for the in-flight request before deciding. If the response that completes the upload is already in, the upload completes, done returns the stored object, and no DELETE is sent. Before, done failed with ResumableUploadCancelledException for an object that was already stored. While a cancel is pending, pause() and resume() do nothing, and calling cancel() again returns the same future.
  • Unreadable records are kept. Each stored record is parsed on its own. One the package cannot read, such as a record written by a newer version, is skipped and written back unchanged. Before, it dropped every record after it, and the next save deleted them for good.
  • Signed uploads stay unauthenticated after a restart. resumeUpload, resumeUploadBinary and discardResumableUpload no longer send the client's headers for a record that holds a signed upload token, which matches how the upload was started.
  • One project ref derivation. The record key and the session key both come from a new projectRef helper in supabase_common.
  • Docs: fileOptions.headers are sent with every request of the upload but are not recorded, so an upload continued after a restart goes without them.

Not changed

When the HEAD after a lost final response reports every byte received, but carries no Supabase-Object-Id, the upload still fails, as the spec requires. Current storage servers set that header on such a HEAD (onUploadHead in src/http/routes/tus/lifecycle.ts).

Tests

New unit tests:

  • a failed upload resumed through the same handle
  • cancel racing the final chunk
  • an unreadable record kept across writes

All suites pass: storage (390, 15 skipped by an existing lifecycle condition), supabase_common, supabase and supabase_flutter.

@github-actions github-actions Bot added the storage This issue or pull request is related to storage label Oct 19, 2026
@spydon
spydon merged commit bec2d2d into main Oct 19, 2026
40 checks passed
@spydon
spydon deleted the lukasklingsbo/sdk-2276-resumable-upload-review-fixes branch October 19, 2026 14:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

storage This issue or pull request is related to storage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant