Skip to content

fix(generator): add a per-call timeout to the LLM generation request#3

Open
JoshuaBearup wants to merge 1 commit into
orlyjamie:mainfrom
JoshuaBearup:fix/generation-call-timeout
Open

fix(generator): add a per-call timeout to the LLM generation request#3
JoshuaBearup wants to merge 1 commit into
orlyjamie:mainfrom
JoshuaBearup:fix/generation-call-timeout

Conversation

@JoshuaBearup

Copy link
Copy Markdown

What

Adds a hard per-call timeout to callLLM() in generator/call-llm.mjs.

Why

The generation request fetched api.anthropic.com with no timeout:

const res = await fetch('https://api.anthropic.com/v1/messages', { ... })

If that request stalls (network blip, provider hang), there's nothing to interrupt it — the whole deploy wedges indefinitely with no error and no recovery. I hit exactly this: a generation call that never returned, leaving the deploy stuck.

Fix

Wrap the fetch in an AbortController with a configurable timeout (POLYRANGE_CALL_TIMEOUT_MS, default 150000ms). On expiry the request aborts and callLLM rejects with LLM call timed out after Nms, so the existing retry logic can recover instead of hanging.

Testing

node -c clean. Verified the timeout path with POLYRANGE_CALL_TIMEOUT_MS=1: the call rejects fast with LLM call timed out after 1ms instead of hanging. Default behaviour is unchanged (150s ceiling, only trips on a genuine stall).

callLLM() fetched api.anthropic.com with no timeout, so a stalled request
hung the entire deploy indefinitely (observed: a generation call that
never returned, leaving the deploy wedged with no error).

Wrap the fetch in an AbortController with a configurable timeout
(POLYRANGE_CALL_TIMEOUT_MS, default 150000ms). On expiry the request is
aborted and callLLM rejects with "LLM call timed out after Nms", so the
caller's retry logic can recover instead of hanging.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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