Repository navigation
fix(providers): report provider timeouts as REQUEST_TIMEOUT in every adapter - #317
Merged
nathanschmid08 merged 1 commit intoNov 12, 2026
Merged
Conversation
…adapter OpenAI, Google and Ollama (generation timer) now throw RequestTimeoutError (504) when their own timer fires, like Anthropic already does. The Ollama connect timeout stays ProviderUnavailableError (503). Also guard Ollama's error-body parsing against a non-string `error`. Closes Open-Glassbeetle#316
Contributor
|
Hi @nova-loop , Thanks for the PR. I really appreciate it. I just finished reviewing everything and it looks really good, therefore I will merge it now. Thanks again and have a great day! |
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.
What changed
A provider timeout is now
RequestTimeoutError(REQUEST_TIMEOUT, 504) in all four adapters, not just Anthropic. This follows the issue's suggested fix:timedOutbranch inexecuteFetchthrowsRequestTimeoutErrorinstead ofProviderUnavailableError. It's the one-word swap plus the import.executeFetchhas atimedOutflag now. The timer sets it, and the catch checks it before the cancellation branch, so the abort reason's shape no longer decides how the error is classified. The timer still aborts with its descriptiveErrorreason. The new message isRequest to Google Gemini timed out after <n>ms.generationTimedOutflag next toconnectTimedOut. A generation timeout throwsRequestTimeoutError(Ollama generation timed out after <n>ms). The connect timeout is unchanged: it is stillProviderUnavailableErrorwith the "Ollama is not running at …ollama serve" message. Caller cancellation is checked first, as before.ollama.adapter.tshandleErrorResponse.body.erroris only used when it is a string, so an object-shapederrorno longer makesmapErrorthrow aTypeError. The status-based mapping applies instead (e.g. 404 →MODEL_NOT_FOUND).Why
Closes #316
503 tells the user the provider is not there. 504 tells them it is there but didn't finish in time. Before this change, which one you got for the same timeout depended on the provider you had picked.
How it was tested
ProviderUnavailableError, which is the behaviour the issue describes as wrong. It now assertsRequestTimeoutErrorwithcodeREQUEST_TIMEOUTandstatusCode504.Timeoutsblock. A hanging fetch withtimeoutMs: 30givesRequestTimeoutError/504. A second test checks that a caller abort is stillRequestAbortedError.generationTimeoutMs: 25) givesRequestTimeoutError/504. The existing connect-timeout test now also assertsPROVIDER_UNAVAILABLE/503. There's also a non-Ollama-shaped 404 body ({"error":{"message":…}}) →ModelNotFoundErrortest.init.signal.reason, as realfetchdoes when aborted with a reason. That is the path Google's classification used to depend on.npm run lint -w @glassbeetle/api(oxlint): clean.npx vitest runinapps/api: 119 files, 1897 tests pass. The e2e config (vitest.config.e2e.ts): 25 files, 822 tests pass.tsc -p tsconfig.build.json --noEmitfor the API: clean. I did not run the rootnpm run buildfor the web/desktop workspaces, since nothing there changed.prettier --checkonmain(The format check has never run in CI, and 92 committed files no longer pass it #246). I kept the new lines formatted and did not reformat the rest of those files, to keep the diff focused.Anything left out, or worth a second opinion
isConnectedonly becomes true whenfetchresolves, i.e. when response headers arrive, and both timers are cleared at that point. With the defaults (connect 5 s, generation 300 s), a request still waiting for headers hits the connect timer first. So the generation timer only wins when it is set shorter than the connect timer, which is what the new test does. I didn't change the timer semantics, since that is outside this issue. It might be worth checking whether a non-streamingcomplete()against a slow local model (Ollama sends headers only when generation finishes) gets cut off at 5 s.Checklist
npm run lint -w @glassbeetle/apipasses (API changes)npm testpasses (API unit + e2e suites; see above)npm run buildpasses (only the APItscbuild was run)http-mapping.tsalready documents 503 vs 504)AI assistance
This change was prepared with AI assistance. An AI coding assistant wrote the code and tests from the issue. I reviewed the diff and ran the checks listed above before opening the PR.