feat(client): add connect_timeout to bound the connect phase - #1324
Draft
fatih-acar wants to merge 1 commit into
Draft
feat(client): add connect_timeout to bound the connect phase#1324fatih-acar wants to merge 1 commit into
fatih-acar wants to merge 1 commit into
Conversation
The SDK passed a single integer timeout to httpx, which applied it to the connect phase as well, so an unreachable address consumed the whole request budget (60s by default) before failing. A new connect_timeout setting (default 10s, INFRAHUB_CONNECT_TIMEOUT) now bounds the TCP/TLS handshake on every request path, capped by the per-request timeout. Since the transient retry handler already treats a connect timeout as a lost connection, a client behind a DNS round robin or a failing-over load balancer now moves on to its next attempt after connect_timeout seconds instead of waiting out the full request timeout. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Deploying infrahub-sdk-python with
|
| Latest commit: |
a40ccf7
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://87dd73a0.infrahub-sdk-python.pages.dev |
| Branch Preview URL: | https://fac-dns-round-robin-5x8wr.infrahub-sdk-python.pages.dev |
Codecov Report✅ All modified and coverable lines are covered by tests. @@ Coverage Diff @@
## stable #1324 +/- ##
==========================================
- Coverage 84.88% 84.86% -0.02%
==========================================
Files 148 148
Lines 13309 13291 -18
Branches 1965 1955 -10
==========================================
- Hits 11297 11280 -17
Misses 1442 1442
+ Partials 570 569 -1
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 2 files with indirect coverage changes 🚀 New features to boost your workflow:
|
fatih-acar
force-pushed
the
fac/dns-round-robin-5x8wr
branch
from
September 8, 2026 16:45
2a84404 to
a40ccf7
Compare
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.
Summary
An Infrahub endpoint that does not answer the TCP or TLS handshake used to hold every SDK request for the full request timeout (60 seconds by default) before failing. This PR bounds the connect phase separately, so a client behind a DNS round robin or a failing-over load balancer moves on to its next attempt after a few seconds instead of waiting out the whole request budget.
Key Changes
connect_timeoutsetting (default 10 seconds,INFRAHUB_CONNECT_TIMEOUT) bounds the TCP/TLS handshake on every request path: regular requests, multipart uploads and streaming downloads, on both the async and sync clients. It never exceeds the per-requesttimeout.timeoutsetting's description now states what it covers (read, write and pool phases) instead of calling itself a "connection timeout". No behaviour change.The transient retry handler on
stablealready treats a connect timeout as a lost connection and retries it whenretry_on_failureis enabled, so this PR only shortens how long each failed attempt takes. An earlier revision of this PR also carried that retry mapping; it was dropped during the rebase ontostable.Documentation Updates
docs/docs/python-sdk/reference/config.mdxregenerated with the new setting.changelog/.Test Plan
uv run pytest tests/unit/sdk/test_connect_timeout.pycovers the config default and validation, the exact timeout httpx receives on every path for both clients, the cap by the request timeout, and that a connect timeout still surfaces asServerNotReachableErrorand is retried throughexecute_graphql.uv run invoke format lint-codeanduv run invoke docs-validatepass locally.tests/unitsuite passes except three pre-existinginfrahubctltable-rendering failures that fail identically onstable.