Skip to content

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

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

feat: default requests to a 30 second timeout#540
razor-x wants to merge 3 commits 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, python, csharp).

Problem

Requests had no timeout of their own and fell back to the Net::HTTP defaults, so a hung connection could block the caller far longer than the API would ever take to respond.

Changes

  • Set the Faraday timeout and open_timeout to 30 seconds by default, matching the API's own request timeout.
  • Add a timeout option, in seconds, to the constructor and the factory methods on Seam, Seam::Http, SingleWorkspace, and MultiWorkspace.
  • faraday_options still deep merges over the default, so either timeout can be set independently.
seam = Seam.new(api_key: "your-api-key", timeout: 60)

# Or set them independently
seam = Seam.new(
  api_key: "your-api-key",
  faraday_options: {request: {timeout: 60, open_timeout: 5}}
)

A single timeout: sets both values on purpose. Setting only the read timeout would leave a hung TCP connect on Net::HTTP's 60 second default and undercut the point of the change.

Behavior change

Requests that previously ran longer than 30 seconds will now raise Faraday::TimeoutError. The timeout option is the opt-out.

Testing

92 examples, 0 failures. standardrb is clean.

spec/seam_client/timeout_spec.rb is new. The existing faraday_options spec asserted a timeout of 30, which is now also the default and so no longer proved anything — it moves to 45 to keep testing the merge.

Note for reviewers

Retries multiply the timeout. With the default of 2 retries, a fully hung endpoint is now bounded at roughly 90 seconds rather than far longer. Retry behavior is otherwise untouched here.

🤖 Generated with Claude Code

https://claude.ai/code/session_01XMgDauUA2R9u2THCHmMgv1


Generated by Claude Code

claude and others added 2 commits August 6, 2026 08:13
Requests had no timeout of their own and fell back to the Net::HTTP
defaults, so a hung connection could block the caller far longer than
the API would ever take to respond.

Set the Faraday `timeout` and `open_timeout` to 30 seconds, matching the
API's own request timeout, and add a `timeout` option so callers can
raise or lower it. `faraday_options` still deep merges over the default,
so either timeout can be set independently.

The faraday_options spec asserted a timeout of 30, which is now also the
default, so it moves to 45 to keep proving the merge.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XMgDauUA2R9u2THCHmMgv1
A file per constant does not scale. default_endpoint.rb and
default_timeout.rb become defaults.rb, which the new constants can join.

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.

3 participants