mirror of
https://github.com/supabase/supabase.git
synced 2026-12-03 23:18:57 +00:00
## Problem The storage buckets queries (`usePaginatedBucketsQuery`, `useBucketQuery`) override the global retry rule with `shouldRetryBucketsQuery`, which retried every error except 404 and two specific messages. A permanent client error, such as a 402 returned when a project's service is restricted, was retried 3 times with exponential backoff. The Storage files page showed its loading skeleton for that whole time instead of the error that `FilesBuckets` already renders. ## Solution `shouldRetryBucketsQuery` now skips retries for any 4xx response except 429. This matches the global default in `data/query-client.ts`. The existing checks for 404, "Missing tenant config" and "Project has no active API keys" are kept, with 404 now covered by the 4xx rule. 5xx and 429 errors are still retried up to `MAX_RETRY_FAILURE_COUNT`. The function is exported so it can be unit-tested, and `data/storage/buckets-query.test.ts` covers the new behaviour. Checks run: - `pnpm exec vitest run data/storage/buckets-query.test.ts` (3 passed) - `pnpm turbo run typecheck --filter='...[origin/master]'` - `pnpm turbo run lint --filter='[origin/master]'` - prettier `--check` on the changed files ## Review instructions 1. Open Storage > Files (`/project/<ref>/storage/files`) for a project whose buckets request returns a 4xx (for example a 402 for a restricted project). The "Failed to retrieve buckets" error with the API message shows after one request, with no long loading state. 2. Open the same page for a healthy project. Buckets load and list as before. ## Checklist - [x] I have read [CONTRIBUTING.md](https://github.com/supabase/supabase/blob/master/CONTRIBUTING.md) - [x] If I wrote a new docs topic or edited an existing topic, I used the `/write-the-docs` or `/edit-the-docs` skill, which applies the docs [style guide](https://github.com/supabase/supabase/tree/master/apps/docs/style-guide) [FE-4925](https://linear.app/supabase/issue/FE-4925/storage-loads-endlessly-without-showing-error-message-if-organization) Co-authored-by: supabase-vercel-tedd[bot] <336548405+supabase-vercel-tedd[bot]@users.noreply.github.com>
28 lines
990 B
TypeScript
28 lines
990 B
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import { shouldRetryBucketsQuery } from './buckets-query'
|
|
import { classifyResponseError } from '@/data/error-classification'
|
|
|
|
describe('shouldRetryBucketsQuery', () => {
|
|
it('does not retry client errors', () => {
|
|
for (const code of [400, 402, 403, 404]) {
|
|
expect(shouldRetryBucketsQuery(0, classifyResponseError({ message: 'error', code }))).toBe(
|
|
false
|
|
)
|
|
}
|
|
})
|
|
|
|
it('retries rate limits and server errors up to the limit', () => {
|
|
for (const code of [429, 500, 503]) {
|
|
const error = classifyResponseError({ message: 'error', code })
|
|
expect(shouldRetryBucketsQuery(0, error)).toBe(true)
|
|
expect(shouldRetryBucketsQuery(3, error)).toBe(false)
|
|
}
|
|
})
|
|
|
|
it('does not retry when the project has no active API keys', () => {
|
|
const error = classifyResponseError({ message: 'Project has no active API keys', code: 500 })
|
|
expect(shouldRetryBucketsQuery(0, error)).toBe(false)
|
|
})
|
|
})
|