Repository navigation
fix(postgrest): apply normalized timeout to internal httpx clients - #1758
Open
AleksaMCode wants to merge 1 commit into
Open
AleksaMCode wants to merge 1 commit into
AleksaMCode wants to merge 1 commit into
Conversation
This branch has not been deployed
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.
What kind of change does this PR introduce?
Bug fix (PostgREST client timeout handling) + regression tests. Before applying the fix my tests would fail with:
What is the current behavior?
When constructing
SyncPostgrestClient/AsyncPostgrestClientwithout a customhttp_client, the client computes a normalized timeout (self.timeout) and defaults it toDEFAULT_POSTGREST_CLIENT_TIMEOUT(120), but the internal HTTPX client is created with the rawtimeoutargument instead.As a result, omitting
timeoutfalls back to HTTPX defaults (about 5s per phase) instead of the intended PostgREST default.I discovered this during usage when request timeout behavior was shorter than expected.
Relevant paths:
src/postgrest/src/postgrest/_sync/client.pysrc/postgrest/src/postgrest/_async/client.pyWhat is the new behavior?
The internal HTTPX clients now use the normalized timeout (
self.timeout) so runtime behavior matches the PostgREST client default and constructor logic.This PR also adds regression tests (sync + async) that verify default timeout behavior when no custom
http_clientis supplied:src/postgrest/tests/_sync/test_client.pysrc/postgrest/tests/_async/test_client.pyAdditional context
This change keeps behavior for custom
http_clientunchanged (caller-managed timeout still applies there).I added tests first to capture the bug, confirmed they fail against current behavior, then applied the minimal fix.