Skip to content

fix: give every default HTTP client a connect/total timeout - #98

Open
zaoldyeck wants to merge 1 commit into
Polymarket:mainfrom
zaoldyeck:fix/default-http-timeouts
Open

fix: give every default HTTP client a connect/total timeout#98
zaoldyeck wants to merge 1 commit into
Polymarket:mainfrom
zaoldyeck:fix/default-http-timeouts

Conversation

@zaoldyeck

@zaoldyeck zaoldyeck commented Jul 31, 2026

Copy link
Copy Markdown

Problem

reqwest::Client ships with no timeout by default, and all four sub-clients (clob / gamma / data / bridge) build their default client without setting one. A single hung TCP connection — a dropped SYN-ACK, a stalled middlebox — wedges the calling task forever: no error, no return. We measured exactly this failure class live (a task hung 17+ minutes on a network blip until externally killed).

Fix

connect_timeout(10s) + timeout(30s) on the default builders. Both are far above any healthy response from these APIs, while guaranteeing the caller always gets control back. Callers with different budgets can keep constructing and injecting their own client, as before.

🤖 Generated with Claude Code

https://claude.ai/code/session_01CRy5VdMgLHQ1EB9WgqxP3p


Note

Medium Risk
Default timeouts apply to all four API surfaces, including CLOB; legitimately slow calls may now surface timeout errors instead of hanging, which can affect trading and automation that relied on unbounded waits.

Overview
Adds 10s connect and 30s total request timeouts on the built-in reqwest clients in bridge, clob, data, and gamma Client::new, so hung connections fail instead of blocking forever.

Each builder gets a short comment explaining why reqwest has no default timeout. Callers who need different limits can still supply their own HTTP client where the API allows it.

Reviewed by Cursor Bugbot for commit 91c9257. Bugbot is set up for automated code reviews on this repo. Configure here.

reqwest's Client has no timeout by default, so one hung TCP connection
(a dropped SYN-ACK, a stalled proxy) wedges the calling task forever —
no error, no return. All four sub-clients (clob/gamma/data/bridge) built
their default client without one.

10s connect / 30s total: far above any healthy response from these APIs,
while guaranteeing the caller always gets control back. Callers that need
different budgets can keep constructing their own client.
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