Repository navigation
fix storage.download() returns stale/cached data after file updates - #41855
Adityakk9031 wants to merge 2 commits into
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@Adityakk9031 is attempting to deploy a commit to the Supabase Team on Vercel. A member of the Team first needs to authorize it. |
|
Thanks for contributing to Supabase! ❤️ Our team will review your PR. A few tips for a smoother review process:
|
WalkthroughAdds an Admonition to the Storage Quickstart documentation noting that downloaded files can be stale due to caching and shows how to fetch the latest version by creating a signed URL and using Changes
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (2)
apps/docs/content/guides/storage/quickstart.mdx (2)
199-216: Documentation addition looks good overall.The workaround is appropriate for the caching issue described in the linked issue. A few minor suggestions to improve clarity:
- The
blobvariable is created but not shown being used—consider adding a brief comment or showing what to do with it (e.g.,// Use blob as needed).- Consider adding basic error handling or a note that production code should check
response.ok.- The 60-second expiry is fine, but a brief inline comment explaining it's the URL validity duration could help newcomers.
📝 Suggested improvement for the code example
const { data } = await supabase.storage .from('avatars') - .createSignedUrl('public/avatar1.png', 60) + .createSignedUrl('public/avatar1.png', 60) // URL valid for 60 seconds if (data) { const response = await fetch(data.signedUrl, { cache: 'no-store' }) const blob = await response.blob() + // Use blob as needed (e.g., create object URL, read as text, etc.) }
218-257: Consider adding similar cache workaround notes for other SDK tabs.The caching issue may also affect Dart, Swift, and Python SDKs depending on the underlying HTTP client behavior. Users of those SDKs might encounter the same stale data problem but won't see any guidance.
You may want to verify whether the other SDKs (Dart, Swift, Python) have similar caching behavior and, if so, add equivalent workarounds or at minimum a note directing users to a common solution.
📜 Review details
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/docs/content/guides/storage/quickstart.mdx
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2026-01-05T23:42:52.357Z
Learnt from: kallebysantos
Repo: supabase/supabase PR: 41727
File: apps/docs/content/guides/functions/auth.mdx:93-93
Timestamp: 2026-01-05T23:42:52.357Z
Learning: When reviewing MDX documentation that uses CodeSample components in Supabase docs, it's acceptable for CodeSample meta attributes to display generic example file names (e.g., hello/index.ts) to illustrate templating. Do not flag these as file-path mismatches unless the docs claim an exact reference to a real file. If you encounter such code samples, ensure the surrounding text clarifies that the names are placeholders to be adapted by users, and suggest adding a note explaining how to map the template to a real project path.
Applied to files:
apps/docs/content/guides/storage/quickstart.mdx
|
Hi @Adityakk9031! Thank you for documenting a workaround for this issue. However, we're going to close this PR because we're fixing the root cause in the SDK instead. Why We're Not Merging ThisWhile your workaround technically works, it has some issues:
The Proper FixWe're fixing this in the SDK itself by exposing fetch parameters in the Once released, the clean solution will be: // Edge Functions - bypass cache
const { data, error } = await supabase.storage
.from('avatars')
.download('file.png', {}, { cache: 'no-store' })
// Default (browsers/Node.js)
const { data, error } = await supabase.storage
.from('avatars')
.download('file.png')And I'll make sure to document this. Thank you very much for contributing to Supabase! Your contributions is what makes our tools better 💚 |
Issue
storage.download() returns stale data because it uses the default fetch behavior which may cache responses, and the method currently provides no way to pass Cache-Control headers or options to opt-out of this caching (e.g. no-store). This is particularly problematic in environments like Supabase Edge Functions (Deno).
Solution
Updated the documentation in
apps/docs/content/guides/storage/quickstart.mdx
to provide a verified workaround. The guide now includes an example of using createSignedUrl combined with fetch(..., { cache: 'no-store' }) to ensure fresh data retrieval.
Includes inline comments to clarify URL validity and blob usage, incorporating review feedback for better developer experience.
closes:#41841
Summary by CodeRabbit
✏️ Tip: You can customize this high-level summary in your review settings.