fix: add timeout to opencode connection testing#261
Merged
dimavedenyapin merged 1 commit intomainfrom Apr 20, 2026
Merged
Conversation
…te hangs The sharedClient used noTimeoutFetch (infinite timeout) for all operations including config.providers() and config.update() calls during connection testing. This caused "Testing connection..." to hang for minutes when the opencode server was slow to respond. Add a separate quickClient with 15s timeout for health checks, provider listing, and config push operations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.
Summary
The OpenCode server (TypeScript, not Go) lazily initializes
InstanceState(providers, models, auth) on the first request that touches instance routes — not at server startup. The SDK'screateOpencoderesolves as soon as the server prints "listening", before providers are loaded.Our adapter called
config.update()(withnoTimeoutFetch= infinite timeout) in three places, each triggering this lazy init:ensureServerRunning— config push with auth.json keyscreateSession— plugin registrationresumeSession— plugin registrationThe lazy init involves network calls (
models.dev/api.json, plugin auth loaders for custom providers likerouterai.ru,api.featherless.ai) that can block for minutes on slow networks. With infinite timeout on all SDK calls, both the Settings → Agents "Testing connection..." and the transcript session startup would hang indefinitely.Changes
quickClientwith 15s timeout for health checks, provider listing, and config queriesconfig.update()calls fire-and-forget — they trigger the expensive lazy init but don't need to block session startup or connection testingRoot cause confirmed from source
InstanceState.make()withModelsDev.get()and plugin loadersmodels.dev/api.json(10s timeout), plugin auth loaders (no timeout)InstanceStateinit completesTest plan
sharedClientwith no timeout)🤖 Generated with Claude Code