Repository navigation
Conversation
Contributor
Author
|
hi @o-santi, can you help me review this one please |
spydon
added a commit
that referenced
this pull request
Nov 2, 2026
## What
Adds a client-level option to turn off automatic retries of transient
PostgREST errors (503/520 on GET/HEAD), matching `db.retry` in
supabase-js.
- `ClientOptions.postgrest_client_retry` (default `True`) is forwarded
to the PostgREST client as `retry_enabled`.
- `AsyncPostgrestClient`/`SyncPostgrestClient` accept `retry_enabled`
and carry it through `schema()`, `from_()`/`table()` and `rpc()` into
every request builder.
- The per-request `.retry()` override still takes precedence.
- `ClientOptions.replace()` keeps `postgrest_client_retry` and accepts a
new value for it.
- The `database.configuration.auto_retry` note in `sdk-compliance.yaml`
now describes the client-wide option.
```python
options = ClientOptions(postgrest_client_retry=False)
client = create_client(url, key, options)
client.table("t").select("*").execute() # no retries
client.table("t").select("*").retry(True).execute() # retries for this request
```
## Notes
Supersedes #1604 by @PhuocOng, moved onto current `main` with the
conflicts resolved. Changes since that PR:
- Only the `_async` sources and tests are edited by hand. The `_sync`
trees are generated.
- Tests patch `get_retry_delay` instead of `asyncio.sleep` with
`AsyncMock`, so the generated sync tests work.
- `ClientOptions.replace()` now carries the new field, so it isn't
dropped.
Closes #1561
Linear: SDK-2641
Co-authored-by: Peter Ong <[email protected]>
Contributor
|
Thanks for the work on this! This has been superseded by #1900, which builds on your changes (with you credited as co-author) and is now merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #1561.
Adds
postgrest_client_retry(defaultTrue) toClientOptions, mirroringpostgrest_client_timeout, and forwards it to the PostgREST client as a newretry_enabledconstructor option. The flag propagates throughschema(),from_()/table()andrpc()into every request builder, sopostgrest_client_retry=Falsedisables 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.
_syncmirrors_async.sdk-compliance.yamlgets a note ondatabase.configuration.auto_retryfor 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_syncfiles are line-for-line mirrors, and the rest of the diff is tests.Tests (
TestRetryEnabled, async and sync): the flag propagates throughfrom_/rpc/schema; and, withsession.sendpatched to always answer 503, a client created withretry_enabled=Falsesends exactly one request, a per-request.retry(True)on that client sends1 + MAX_RETRIES, and the default client also sends1 + MAX_RETRIES.test_postgrest_client_retry_optioncovers theClientOptionspath in supabase. Locally: postgrest 210 passed (integration excluded), supabase 32 passed, mypy clean for both packages, ruff clean.