anomalyco / anomalyco/opencode

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

Open
#48,917 0 comments 0 reactions 1 assignee View on GitHub

@nexxeln is already working on this.

Since Sep 14, 2026.

Dominant language
TypeScript
Stars
209k
Forks
27.5k
PR merge metrics
PR metrics pending

Description

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 servecreating 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

  • Lazy instance creation: initialize an instance on first request for that directory, not at listen time.
  • Or parallelize InstanceStore.boot and skip directories that no longer exist on disk.
  • Related: #36840 reports the same eager bootstrap deadlocking under concurrent triggers on WSL2 — lazy init would help there too.

Also encountered on the same install

  • #42170 — SQLiteError: no such column: project_id from Project.migrateProjectId inside this same boot path; resolved manually with the workspace table drop/recreate posted in that thread.

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.