Skip to content

feat(postgrest): add client-level retry toggle (postgrest_client_retry) - #1604

Open
PhuocOng wants to merge 1 commit into
supabase:mainfrom
PhuocOng:feat/postgrest-retry-option
Open

feat(postgrest): add client-level retry toggle (postgrest_client_retry)#1604
PhuocOng wants to merge 1 commit into
supabase:mainfrom
PhuocOng:feat/postgrest-retry-option

Conversation

@PhuocOng

@PhuocOng PhuocOng commented Sep 2, 2026

Copy link
Copy Markdown

Closes #1561.

Adds postgrest_client_retry (default True) to ClientOptions, mirroring postgrest_client_timeout, and forwards it to the PostgREST client as a new retry_enabled constructor option. The flag propagates through schema(), from_()/table() and rpc() into every request builder, so postgrest_client_retry=False disables the automatic retry of transient PostgREST errors for the whole client. The existing per-request .retry() override still takes precedence.

No behavior change by default. _sync mirrors _async. sdk-compliance.yaml gets a note on database.configuration.auto_retry for the client-wide option.

Review guide: the logic lives in four files (postgrest/_async/client.py, postgrest/_async/request_builder.py, supabase/_async/client.py, supabase/lib/client_options.py); the _sync files are line-for-line mirrors, and the rest of the diff is tests.

Tests (TestRetryEnabled, async and sync): the flag propagates through from_/rpc/schema; and, with session.send patched to always answer 503, a client created with retry_enabled=False sends exactly one request, a per-request .retry(True) on that client sends 1 + MAX_RETRIES, and the default client also sends 1 + MAX_RETRIES. test_postgrest_client_retry_option covers the ClientOptions path in supabase. Locally: postgrest 210 passed (integration excluded), supabase 32 passed, mypy clean for both packages, ruff clean.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

parity(client): add db.retry option to disable transient PostgREST retries [from supabase-js]

1 participant