fix: prevent config handler deadlock on fresh installs #1296
+22
−4
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
fetchAvailableModels(ctx.client)during OpenCode bootstrap, before the server is ready to handle requestsclient.provider.list()which sends an HTTP request back to the OpenCode serverRoot cause
This is a regression from 80ee52f which re-introduced client API calls as a fallback in
fetchAvailableModels, undoing the fix in ab3e622 ("fix: use cache file for model availability instead of SDK calls") that explicitly made the client parameter unused (_client) to prevent this exact deadlock.Why it appears platform-specific
The issue was reported as Linux-only, but it's actually a fresh-install problem:
connected-providers.jsoncache is only written by thesession.createdevent handlerreadConnectedProvidersCache()returnsnull→connectedProvidersUnknown = true→ client API call → deadlockChanges
config-handler.ts: Passundefinedinstead ofctx.clienttocreateBuiltinAgents()andfetchAvailableModels()during the config phase, forcing cache-only model resolution (same approach as ab3e622)manager.ts: Add 3-second force-exit timeout to SIGINT handler so Ctrl+C always terminates even when cleanup API calls hang on a deadlocked serverTest plan
~/.cache/oh-my-opencode/connected-providers.jsondoes not exist on fresh install/providerrequest stuck at "started" indefinitely (deadlock)🤖 Generated with Claude Code
Summary by cubic
Prevents a startup deadlock on fresh installs by avoiding client API calls during config bootstrap. Adds a 3s force-exit on SIGINT so Ctrl+C still works if cleanup hangs.
Written for commit b21e42d. Summary will update on new commits.