Skip to content

Re-Consider the Automatic-Retry Contract #85

Open

Description

@QuintinWillison

In response to Claude's review of #78.

🤖 Claude-generated Issue Summary

configuration.WithRetry documents that each domain client defines which requests qualify for automatic retries. The database module retries idempotent reads with backoff and Retry-After support. The auth module currently retries nothing, documented as such, since verification calls sit on request-handling hot paths and retrying the JWK Set fetch or GetUser fallback multiplies both caller latency and Auth-server traffic.

Decide whether auth should honour the option on its idempotent GETs (which means lifting the retry transport from postgrest/internal/http into shared internals) or whether the option should be explicitly scoped to the database module in its own documentation. Either outcome should land with docs making the scope obvious to a consumer setting the option on a shared configuration.

Activity

  1. added
    auth
    on Sep 14, 2026
  2. grdsdev commented on Nov 26, 2026

    @grdsdev
    Contributor

    The capability matrix now has a spec for this contract on the database side: database.configuration.auto_retry, in review in supabase/sdk#190. It does not settle the auth scope question in this issue. It does list four points where postgrest/internal/exchange/exchange.go differs from the spec:

    • No jitter. The wait is time.Second << attempt. The spec: full jitter, a random wait in [0, min(30 s, 1 s × 2^(n−1))], a new value for each wait.
    • Retry-After has no cap. Retry-After: 3600 makes the request wait one hour. The spec: a value over 30 s ends the retries, and that response is the outcome.
    • Retry-After as an HTTP-date is not read. It falls back to the backoff, which is safe, but the spec reads both delta-seconds and HTTP-date.
    • Retry-After: 0 retries at once. The spec: 0, or a date that has passed, falls back to the jittered wait.

    The rest already matches: GET/HEAD only, 503/520, 4 attempts in total, X-Retry-Count, the per-client switch and the per-read override in both directions, cancellation, and no retry of token-callback errors. The 401 re-send that shares the attempt budget is allowed by the access-token spec.

    There is no Storage module, so storage.configuration.auto_retry does not apply.

  3. QuintinWillison commented on Nov 26, 2026

    @QuintinWillison
    MemberAuthor

    Thanks @grdsdev, all four hold against main at 668e1e5. I'll wait for supabase/sdk#190 to merge before working on them, with one exception: Retry-After: 0, which I'll pick up now as a quick win.

    Two notes for you, no action needed:

    • Retry-After: 0 is the common case, not an edge case. Since v12.2.2, every 503 from the PostgREST server carries it, because PostgREST/postgrest@f09655b stopped updating the value. So today this SDK retries a read that gets a 503 three times with no wait, which is why I'm not waiting on this one. It also backs the 0 rule in docs(capability-matrix): add specs for database and storage auto_retry sdk#190.
    • A fifth difference. Cancellation doesn't fully match: when an attempt fails with a network error and the caller's context ends during the wait that follows, the call returns the network error rather than the cancellation (exchange.go L171-L178). I'll fix it with the rest.

    Written with assistance from my friend, and yours, 🤖 Claude.

    Spider Claude. Spider Claude.
    Does whatever a Spider Claude does.
    Can it swing from a web? No it can't. It's an AI. 🐷

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

    auth

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions