Skip to content

SMOODEV-2513: Connect timeout for Python fetch SDK (parity with #88)#90

Open
brentrager wants to merge 1 commit into
mainfrom
SMOODEV-2513-connect-timeout-py
Open

SMOODEV-2513: Connect timeout for Python fetch SDK (parity with #88)#90
brentrager wants to merge 1 commit into
mainfrom
SMOODEV-2513-connect-timeout-py

Conversation

@brentrager

Copy link
Copy Markdown
Contributor

Problem

The Rust fetch SDK gained a bounded connect-phase timeout in #88 (SMOODEV-2498 / SMOODEV-2481): api-prime's ~16s stalls were fresh SYNs to dead pod IPs still lingering in a ClusterIP's iptables. Without a connect timeout, the client waits the full whole-request timeout on a black-holed connect. The Python SDK had no equivalent.

Solution

Add optional connect_timeout_ms: float | None = None to TimeoutOptions. httpx supports per-phase timeouts natively, so when set we construct httpx.Timeout(whole_s, connect=connect_s) — only the connect phase is capped while read/write/pool keep timeout_ms. A black-holed connect now fails fast (surfaced as the SDK's TimeoutError, since httpx.ConnectTimeout subclasses httpx.TimeoutException) instead of hanging until the whole timeout.

Default-off: when connect_timeout_ms is None the timeout construction is byte-identical to before (httpx.Timeout(timeout_seconds)) — existing callers are behavior-identical.

Test

test_connect_timeout_fails_fast_on_black_hole mirrors the Rust connect_timeout_fails_fast_on_black_hole: a request to non-routable http://10.255.255.1:80/ with a 500ms connect timeout and a 10x (5s) whole timeout must raise and return in well under 3s.

  • poe lint / poe format:check / poe typecheck clean
  • poe test: 127 passed

🤖 Generated with Claude Code

Parity with Rust fetch#88. Adds optional connect_timeout_ms to
TimeoutOptions. When set, only the connect phase is capped (via
httpx.Timeout(whole, connect=...)) so black-holed connects fail fast
instead of stalling until the whole-request timeout; the remaining
phases keep timeout_ms. Default None = byte-identical current behavior.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@changeset-bot

changeset-bot Bot commented Jul 10, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 52671f4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

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.

1 participant