fix: bound provider requests with a 60s timeout (scans can no longer hang)#20
Merged
Conversation
…hang) A stalled provider connection had no escape — every fetch() in the AI path lacked an AbortController, so one stuck request froze the *serialized* scan until the output tab's generic 90s "Analysis timed out" fired (output-tab.js:127, which is what users were hitting). - fetchWithTimeout() now wraps all 8 provider fetch sites with a 60s AbortController timeout (well under the 90s tab deadline). - New non-retryable `timeout` error kind: a stall falls straight through to the next provider in the attempt plan instead of re-hammering the stalled one, and surfaces an actionable "took too long — Retry / pick a faster provider" message (errors.js + an output-tab hint). Also fixes the time-flaky maintenance test that was reddening CI on main (pin the clock with vi.setSystemTime), so this branch lands green. 713 tests pass.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The bug
A scan was hanging until the output tab gave up with
Analysis timed out — please try again.(output-tab.js:127, the 90swaitForDatadeadline). Root cause: every providerfetch()in the AI path had noAbortController/timeout, so a stalled connection froze the serialized scan queue indefinitely — the tab's generic 90s timeout was the only escape, and it surfaced no actionable next step.The fix
fetchWithTimeout()wraps all 8 provider fetch sites (callOpenAICompatible,openaiChat,callAnthropicCompatible,callAnthropic,callGemini,callNous,callOpenRouter,callXAI) with a 60sAbortControllertimeout — generous for slow models, well under the 90s tab deadline.timeouterror kind (errors.js): a stall falls straight to the next provider in the attempt plan instead ofwithRetryre-hammering the stuck one (which would've made it worse), and surfaces "{provider} took too long — Retry, or pick a faster provider in Settings" (+ an output-tab hint).errors.test.js— the new kind matches a specifictimed out after Nsphrase, so"Failed to fetch"etc. still classify asnetwork.Also: un-reds CI
The time-flaky
maintenance.test.js(which was failing onmainsince the date rolled over) is fixed by pinning the clock withvi.setSystemTime. So this branch lands on green CI rather than inheriting the pre-existing red.Test plan
npx vitest run— 713 passing (was 711/712 with the flake; +1 new timeout-kind test)node --checkon all 4 edited source filesNote
This is the issue the user hit live (the
output-tab.js:127error). Doesn't change the serial-queue throughput (a separate audit finding) — but it kills the indefinite hang failure mode.🤖 Generated with Claude Code