Skip to content

fix(storage): expose fetch parameters in download method - #2090

Merged
mandarini merged 6 commits into
masterfrom
fix/storage-download-fetch-parameters
Feb 5, 2026
Merged

mandarini merged 6 commits into
masterfrom
fix/storage-download-fetch-parameters

Conversation

@mandarini

@mandarini mandarini commented Feb 4, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Issue #41841 reports that storage.download() returns stale/cached data after file updates, particularly in Supabase Edge Functions (Deno runtime).

The download() method currently doesn't expose a way to pass fetch options like cache: 'no-store' to the underlying HTTP request, even though the infrastructure exists in the get() function.

Solution

Add an optional parameters?: FetchParameters argument to the download() method, following the same pattern already used by the list() method.

This allows users to opt into cache control when needed:

// Edge Functions - bypass cache
const { data } = await supabase.storage
  .from('avatars')
  .download('file.png', {}, { cache: 'no-store' })

// Abort signal support
const controller = new AbortController()
const { data } = await supabase.storage
  .from('avatars')
  .download('file.png', {}, { signal: controller.signal })

// Default behavior (unchanged)
const { data } = await supabase.storage
  .from('avatars')
  .download('file.png')

Inspired by #2022 and @Akkii88, thank you!

Summary by CodeRabbit

  • New Features

    • Downloads now accept optional fetch parameters (including cache directives) for finer control over HTTP caching and other fetch behaviors.
    • Download calls can accept an abort signal and remain backward-compatible.
  • Documentation

    • Added usage examples showing cache control and abort scenarios.
  • Tests

    • Added tests covering cache options, abort behavior, transform usage with fetch parameters, and backward-compatibility.

@coderabbitai

coderabbitai Bot commented Feb 4, 2026 •

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

StorageFileApi.download adds an optional third argument parameters?: FetchParameters that is forwarded to the underlying fetch/get call. FetchParameters gains an optional cache property. Tests were added to validate cache propagation and abort-signal behavior; some test blocks are duplicated in the diff.

Changes

Cohort / File(s) Summary
API update
packages/core/storage-js/src/packages/StorageFileApi.ts
Updated download(path, options?, parameters?) signature; forwards parameters to internal get/fetch call; updated docs and examples to show cache and abort usage.
Types
packages/core/storage-js/src/lib/types.ts
Added `cache?: 'default'
Fetch implementation
packages/core/storage-js/src/lib/common/fetch.ts
Removed local FetchParameters declaration; now imports FetchParameters from ../types (type-only change).
Tests (fetch & download)
packages/core/storage-js/test/common/fetch.test.ts, packages/core/storage-js/test/storageFileApi.test.ts
Added tests covering cache option propagation, cache combined with AbortSignal, support for all cache values, transform with fetch options, and backward-compatibility download without parameters. Note: similar/duplicated test blocks appear in the diff.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and accurately summarizes the primary change: exposing fetch parameters in the download method to resolve caching issues.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/storage-download-fetch-parameters

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added the storage-js Related to the storage-js library. label Feb 4, 2026
@mandarini mandarini self-assigned this Feb 4, 2026
@mandarini
mandarini marked this pull request as ready for review February 4, 2026 16:32
@mandarini
mandarini requested review from a team as code owners February 4, 2026 16:32
@mandarini
mandarini force-pushed the fix/storage-download-fetch-parameters branch from 7a26ac7 to 83b68ed Compare February 5, 2026 11:35
@mandarini
mandarini requested a review from ferhatelmas February 5, 2026 11:35
@pkg-pr-new

pkg-pr-new Bot commented Feb 5, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

@supabase/auth-js

npm i https://pkg.pr.new/@supabase/auth-js@2090

@supabase/functions-js

npm i https://pkg.pr.new/@supabase/functions-js@2090

@supabase/postgrest-js

npm i https://pkg.pr.new/@supabase/postgrest-js@2090

@supabase/realtime-js

npm i https://pkg.pr.new/@supabase/realtime-js@2090

@supabase/storage-js

npm i https://pkg.pr.new/@supabase/storage-js@2090

@supabase/supabase-js

npm i https://pkg.pr.new/@supabase/supabase-js@2090

commit: 2b975f1

@mandarini
mandarini requested a review from ferhatelmas February 5, 2026 12:37
@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 88.073%. first build
when pulling 2b975f1 on fix/storage-download-fetch-parameters
into c4a8a43 on master.

@mandarini
mandarini merged commit 4b87b9d into master Feb 5, 2026
16 checks passed
@mandarini
mandarini deleted the fix/storage-download-fetch-parameters branch February 5, 2026 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

storage-js Related to the storage-js library.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants