Skip to content

serve: InstanceStore.boot eagerly initializes every registered project directory - startup is O(projects), minute-scale #48917

Closed

Description

@Razikale365

Summary

opencode serve runs InstanceStore.boot at listen time, which eagerly initializes an instance for every row in project/project_directory. Each instance pays full init cost (project config load, plugin init, remote MCP client connects, LSP enumeration) — measured ~2–20s per directory. With ~19 projects / ~80 registered directories, the server isn't ready for several minutes. Downstream supervisors that spawn opencode serve and wait for readiness (e.g., Paseo) time out and kill it.

Environment

  • opencode-ai 1.18.30 (npm), Windows 11
  • ~/.local/share/opencode/opencode.db (~3.3GB) accumulated over months of worktree-based sessions

Evidence

Log excerpt from a single run= of opencode serve — creating instance/fromDirectory/bootstrapping repeating per directory, each followed by config loads, plugin init, MCP connects, and the ~35-entry "enabled LSP servers" enumeration:

message="creating instance" directory="C:\\Docker\\regmais"
message=fromDirectory directory="C:\\Docker\\regmais"
message=bootstrapping directory="C:\\Docker\\project-bulldog\\placeholder-folder"
message=bootstrapping directory="C:\\Docker\\fns-inteligencia-operacional"
message=bootstrapping directory="C:\\Docker\\project-bulldog"
message=bootstrapping directory="C:\\Docker\\dispensamais"
message="enabled LSP servers" serverIds="zls, yaml-ls, vue, typescript, ..."   (per instance)
message=init                                                                 (per instance)

Directories bootstrapped include long-dead paths (%TEMP% dirs, removed worktrees) — those rows are never skipped or pruned, they just add boot cost.

In my case the server was still bootstrapping minutes after listen, while a supervisor's readiness probe timed out and SIGTERM'd it.

Suggestions

Also encountered on the same install

Repro

  1. Accumulate projects/dirs in opencode.db (or insert project_directory rows directly).
  2. opencode serve --port <port> and watch log/opencode.log — one creating instance/bootstrapping/init cycle per registered directory before the server is fully ready.
  3. Time to readiness scales roughly linearly with registered directory count.

Activity

  1. neriousy commented on Oct 19, 2026

    @neriousy
    Member

    In v2, the server becomes ready without loading your registered project directories; a directory's config, plugins and MCP servers start only when a request actually needs that directory. Old or deleted directory registrations therefore no longer add to startup time. To get v2: npm i -g @opencode/cli@latest or curl -fsSL https://opencode.ai/v2/install | bash (desktop: update the app). If you still see this on v2, please open a new issue with the details.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions