Skip to content

v3: one shared retry configuration across the clients #1735

Closed

Description

@spydon

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_common documents 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) versus count (retries after the first), and the attempt numbering, since RetryOptions.delay(0) is Duration.zero and its first retry waits 2 * delayFactor while PostgrestRetryOptions.delay(0) waits initialDelay.
  • Replace StorageClientOptions.retryAttempts with 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions