Repository navigation
fix(server): await models before listing - #41783
Merged
Merged
Conversation
kitlangton
marked this pull request as ready for review
August 11, 2026 16:17
jinhuang712
pushed a commit
to jinhuang712/opencode
that referenced
this pull request
Sep 26, 2026
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
Make the first
model.listrequest against a newly started server wait for model-providing plugins to finish initializing. This restoresopencode models --standaloneoutput on cold start instead of silently returning no models.Closes #41071
Before / After
Before: A standalone server became HTTP-ready while
PluginSupervisorwas still activating the initial plugin generation. An immediatemodel.listrequest read the emptyCatalog, returned HTTP 200 withdata: [], and the CLI printed nothing before exiting 0.After:
model.listwaits forPluginSupervisor.flushbefore reading the catalog, matching the existingmodel.defaultreadiness boundary. If initialization does not settle within five seconds, the endpoint returns the existing model-catalog service-unavailable error rather than a successful empty response.How
packages/server/src/handlers/model.tsapplies the existing bounded model-catalog initialization wait tomodel.list.packages/server/test/model.test.tsstarts a fresh server with a configured custom model and immediately requests/api/model, asserting that the cold-start response includes that model.Scope
Testing
bun run test test/model.test.ts --rerun-each 3frompackages/server(3 passes)bun run testfrompackages/server(18 passes, 11 skips)bun typecheckfrompackages/serverbun turbo typecheck --concurrency=3(33 successful tasks)bunx prettier --check src/handlers/model.ts test/model.test.tsfrompackages/serverThe regression test was also run before the handler change and reproduced the bug as HTTP 200 with
{ "data": [] }.