Repository navigation
Description
Summary
Retry is configured differently in every client, and the shared helper in supabase_common is only half used. Raised by @Vinzent03 in #1731 (comment).
Where we stand after #1731:
| Package | User facing configuration | Retried on | Defaults |
|---|---|---|---|
postgrest |
PostgrestRetryOptions(enabled, count, statusCodes, initialDelay, maxDelay, randomizationFactor), plus .retry() per request |
GET and HEAD answering 503/520, network errors, per-attempt timeouts |
3 retries, 1s to 30s, no jitter, on |
supabase_storage |
StorageClientOptions.retryAttempts (int) |
uploads only, ClientException and TimeoutException |
0 retries (opt-in), 200ms factor, 0.25 jitter |
supabase_auth |
nothing | token refresh only, AuthRetryableFetchException, bounded by the refresh deadline |
hardcoded |
supabase_common |
RetryOptions(delayFactor, randomizationFactor, maxDelay, maxAttempts) and a retry() runner |
whatever retryIf says |
8 attempts, 200ms factor, 0.25 jitter |
postgrest uses exponentialBackoff from supabase_common but not its RetryOptions.retry() runner, because that runner only retries thrown exceptions while PostgREST retries on the response status, stamps X-Retry-Count per attempt and has to cooperate with abortSignal and requestTimeout. So the runner genuinely does not fit; the options do.
Proposed change (breaking)
Land one user facing retry options type that every client accepts, and keep the retry loops separate.
- Decide where the shared type lives.
supabase_commondocuments itself as an implementation detail whose API may change without notice, and it is excluded from the capability matrix scan in.sdk-parse-ignore, so its symbols cannot be registered as SDK surface as things stand. Either promote it to public API with matrix coverage or declare the shared type in one client package and re-export it. - Pick one convention for the two mismatches:
maxAttempts(total attempts) versuscount(retries after the first), and the attempt numbering, sinceRetryOptions.delay(0)isDuration.zeroand its first retry waits2 * delayFactorwhilePostgrestRetryOptions.delay(0)waitsinitialDelay. - Replace
StorageClientOptions.retryAttemptswith the shared type, keeping the current storage defaults as its own default instance so behavior does not change. - Give the auth refresh retry the same knobs instead of hardcoding them.
- Keep the per-package predicates (which status codes, which exceptions, which requests) in each client, since they are not interchangeable.
Why v3
Replacing StorageClientOptions.retryAttempts and any renaming inside PostgrestRetryOptions removes public API.
Notes
#1731 already made the postgrest side declarative and named its backoff fields after the supabase_common ones, so aligning them later is a rename rather than a redesign. Follow-up to #1576 and #1594.
Activity
refactor(postgrest)!: expose retry configuration as PostgrestRetryOpt…
refactor!: share one retry configuration across the clients
refactor!: share one retry configuration across the clients (#1738)