Repository navigation
docs(capability-matrix): add specs for database and storage auto_retry - #190
Conversation
|
No actionable comments were generated in the recent review. Summary
Change: Other Merge Risk:
|
a10bf94 to
c00ebb5
Compare
Makes database and storage retries follow the `auto_retry` specs ([supabase/sdk#190](supabase/sdk#190)). Fixes SDK-3240, closes #2143. - **Database:** a forced `retry(True)` no longer sends a write twice. Only GET and HEAD retry, on a network error, 503 or 520, with full jitter. The client and `PostgrestClientOptions` take `retry: bool`. - **Storage:** only reads retry, plus the `list()` POST. Adds 500, and a 429 retries only with `Retry-After`. The client and `StorageClientOptions` take `max_attempts`. Uploads, including the POST that creates a resumable upload, are never retried. - **Auth and functions:** keep `RetryPolicy`, so the global `retry` of the supabase client now applies to them only.
PostgREST's rule is fixed (GET/HEAD, 503/520, 4 attempts, on/off switch only); Storage's is configurable. Both share full-jitter capped backoff, Retry-After honoured up to the cap, stop on cancellation, and no replay of one-shot bodies or of errors thrown by caller-supplied code. Refs SDK-1791, supabase/supabase-swift#1341. Co-Authored-By: Claude <noreply@anthropic.com>
Rewrite both specs as normative contracts per the current TEMPLATE, after comparing the retry code in all seven SDKs. Add a decision flowchart to each. Database: state the per-request override works both ways, define what counts as a transport failure, and stop retrying when Retry-After exceeds the 30 s cap instead of clamping it. Storage: restrict replays to reads (GET, HEAD and the two list POSTs), drop the Idempotency-Key rule that the Storage API does not honour, retry 429 only with Retry-After, make the attempt count the only knob, and stop retries once a streamed download returns.
c00ebb5 to
02c55dd
Compare
…est method (#343) Stacked on #190, which adds the `database.configuration.auto_retry` spec this file links to. Retarget to `main` once #190 merges. Adds `specs/database/query/rpc.md`, which defines which HTTP method a function call uses: - A call is a `POST` unless the caller asks for a read-only call on that call. The SDK never picks `GET` on its own: not from the volatility of the function, not from the shape of the arguments, and not to make the call retryable. Generated function calls (`database.generated_types.typed_rpc`) follow the same rule. - The reasons, each stated as the premise of that rule: PostgREST runs every `GET` read-only, so a `VOLATILE` function that writes fails over `GET` with HTTP 405 `25006`; the Supabase API load balancer sends `GET` to read replicas, so a read right after a write can miss it; and `GET` arguments are part of the URL, which logs record. - A read-only call is sent as `GET` and retried under `auto_retry`. It falls back to `POST`, without retry, when an argument cannot reach the function as a query parameter: a name PostgREST reads as a request option or embed path, a `null`, or a value that starts like a filter (`eq.foo`). Argument values are runtime data, so this changes the method instead of failing the call. - A read-only call whose arguments are not a JSON object of named arguments, such as the whole body of a single unnamed `json` parameter, is rejected before the wire. Checked against the PostgREST docs ([functions](https://docs.postgrest.org/en/latest/references/api/functions.html), [access mode](https://docs.postgrest.org/en/latest/references/transactions.html#access-mode-on-functions)) and the [read replicas guide](https://supabase.com/docs/guides/platform/read-replicas). The filter rule was checked against a local stack: `GET /rpc/get_username_and_status?name_param=eq.supabot` answers HTTP 404 `PGRST202`, because PostgREST reads the parameter as a filter and looks for the function without that argument. This came out of supabase/supabase-flutter#2146 (SDK-2914), where generated calls of `STABLE` functions had been switched to `GET` by the generator. Once this merges, divergences get issues in the SDK repositories that cite this file. `bun run validate` passes (`OK — capability matrix is valid.`), and `bun run test` passes.
Adds spec files for two existing feature IDs that had none. Each spec has a decision flowchart.
database.configuration.auto_retry: a fixed rule.GET/HEADonly,503/520or a network failure, 4 attempts in total, a per-client switch and a per-request override in either direction. Full-jitter backoff (1 s base, 30 s cap).Retry-Afteris honoured up to 30 s; a longer value ends the retries.X-Retry-Count: non the n-th retry. Cancellation, errors from caller-supplied hooks, and decoding errors are never retried.storage.configuration.auto_retry: reads only (GET,HEAD, and the two listPOSTs). Statuses408,429(only withRetry-After),500,502–504,520–524,530. A per-client attempt count (default 3,1turns retries off). Full-jitter backoff (500 ms base, 20 s cap). Retries end when a streamed download returns.How the SDKs compare today
Retry-Afterover capThe divergences from these specs become issues in each SDK repository after merge.
bun run validatepasses. Written alongside supabase/supabase-swift#1341. Linear: SDK-1791.