Skip to content

feat: default requests to a 30 second timeout - #601

Open
razor-x wants to merge 1 commit into
mainfrom
claude/sdk-default-http-timeout-33qknd
Open

feat: default requests to a 30 second timeout#601
razor-x wants to merge 1 commit into
mainfrom
claude/sdk-default-http-timeout-33qknd

Conversation

@razor-x

@razor-x razor-x commented Aug 6, 2026

Copy link
Copy Markdown
Member

Part of a four-SDK change adding a default HTTP timeout (javascript-http, ruby, csharp).

Problem

Requests had no timeout, so a hung connection blocked the caller indefinitely. niquests leaves timeout unset unless it is given.

Changes

  • Pass a 30 second timeout to the niquests session by default, matching the API's own request timeout.
  • Add a timeout option to Seam, SeamMultiWorkspace, and their factory methods.
  • The option takes the niquests forms: a number of seconds, a (connect, read) tuple, or None for no timeout.
seam = Seam(api_key="your-api-key", timeout=60)
seam = Seam(api_key="your-api-key", timeout=(5, 60))
seam = Seam(api_key="your-api-key", timeout=None)  # no timeout

The session-level timeout is passed through Session.__init__ alongside retries, which niquests requires for adapter-mounted options.

Note that timeout=None means no timeout here, following the niquests convention, rather than use the default as retries=None does. That asymmetry is deliberate — None is the only way niquests expresses "no timeout", and disabling the timeout should stay expressible.

Behavior change

Requests that previously ran longer than 30 seconds will now raise niquests.exceptions.Timeout. The timeout option is the opt-out.

Testing

66 tests pass, 5 of them new in test/timeout_test.py, including one that drives a socket server which accepts connections but never responds. black is clean.

Note for reviewers

Retries multiply the timeout, and this SDK's retry default is the steepest of the four. DEFAULT_RETRIES = Retry() is urllib3's default of total=10, so a fully hung endpoint is now bounded at roughly 30s × 11 ≈ 5.5 minutes rather than forever. That is a large improvement over unbounded, but the retry count looks unintentional and is worth a separate look. I left retry behavior untouched here since the ask was timeouts.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XMgDauUA2R9u2THCHmMgv1


Generated by Claude Code

Requests had no timeout, so a hung connection blocked the caller
indefinitely. niquests leaves `timeout` unset unless it is given.

Pass a 30 second `timeout` to the niquests session, matching the API's
own request timeout, and add a `timeout` option to `Seam` and
`SeamMultiWorkspace` so callers can raise or lower it. The option takes
the niquests forms: a number of seconds, a (connect, read) tuple, or
None for no timeout.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XMgDauUA2R9u2THCHmMgv1
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.

2 participants