Skip to content

Commit bf2e94a

Browse files
moose-codeclaude
andcommitted
Tighten Gamma fetch timeout from 2s to 1s
Legitimate Gamma responses are <400ms even under rate-limit pressure; hung sockets stall for 30+ seconds. 1s sits ~2.5x above the worst real latency and aborts dead connections faster, freeing the connection slot to do useful work. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d387807 commit bf2e94a

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/effects/marketMetadata.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,15 @@ export const getMarketMetadata = createEffect(
3131
// params work; the response is wrapped in { markets: [...] } instead
3232
// of being a bare array.
3333
//
34-
// 2s timeout: rare undici-pool connections hang for tens of seconds.
35-
// Throw on timeout/non-2xx so envio does NOT cache the failure — only
36-
// valid data lands in the cache. The OrderFill for this event keeps
37-
// market_id=null; the next event with the same tokenId retries fresh.
34+
// 1s timeout: ~0.5% of Gamma calls hang for 30+ seconds (stale upstream
35+
// sockets). Legitimate responses are <400ms even under rate-limit pressure,
36+
// so 1s is ~2.5× the worst observed real latency. Throw on timeout/non-2xx
37+
// so envio does NOT cache the failure — only valid data lands in the cache.
38+
// The OrderFill for this event keeps market_id=null; the next event with
39+
// the same tokenId retries fresh.
3840
const res = await fetch(
3941
`https://gamma-api.polymarket.com/markets/keyset?clob_token_ids=${tokenId}`,
40-
{ signal: AbortSignal.timeout(2_000) },
42+
{ signal: AbortSignal.timeout(1_000) },
4143
);
4244
if (!res.ok) {
4345
throw new Error(`Gamma API ${res.status} for tokenId ${tokenId}`);

0 commit comments

Comments
 (0)