anomalyco / anomalyco/opencode

plugins: hot reload makes the server unavailable

Open
#42,898 0 comments 0 reactions 1 assignee View on GitHub

@rekram1-node is already working on this.

Since Aug 16, 2026.

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

Description

Description

Editing a local plugin caused the OpenCode server to stop serving model data. The TUI showed an empty model list. I could not authenticate with a provider or start a session. Pressing Esc and restarting the TUI did not help. Restarting the background service restored OpenCode.

This happened twice. In both cases, the server reloaded the plugin and emitted catalog.updated. About five seconds later, GET /api/model returned HTTP 503.

Expected behavior: OpenCode reloads the plugin and remains available. If plugin cleanup fails, OpenCode reports the error without blocking the server.

Log excerpt:

13:23:16.207 loading plugin .../.opencode/plugins/audit-usage.ts?mtime=...
13:23:16.748 event.type=catalog.updated
13:23:21.771 GET /api/model http.status=503
13:27:56.021 GET /api/model http.status=503

13:31:10.660 loading plugin .../.opencode/plugins/audit-usage.ts?mtime=...
13:31:11.205 event.type=catalog.updated
13:31:16.229 GET /api/model http.status=503

The plugin subscribes to ctx.event in a background task. Its cleanup function aborts the subscription and waits for the task, as shown in the V2 plugin documentation. The cleanup might not finish during hot reload.

The plugin was also listed in project config, even though OpenCode automatically discovered it in .opencode/plugins/. The logs show two load entries. I do not know whether this is required to reproduce the bug.

I searched open and closed issues and did not find a duplicate.

Plugins

Local .opencode/plugins/audit-usage.ts plugin

OpenCode version

0.0.0-next-17444

Steps to reproduce
  1. Create a plugin in .opencode/plugins/.
  2. Start a background ctx.event.subscribe loop with an AbortController.
  3. Return a cleanup function that aborts the controller and waits for the task.
  4. Start OpenCode and run a session.
  5. Edit the plugin file.
  6. Open the model list or call GET /api/model.
  7. Check whether the request returns HTTP 503 and the TUI stops working.

In the affected setup, opencode.json also listed the plugin explicitly.

Screenshot and/or share link

No response

Operating System

macOS, Darwin 25.1.0, arm64

Terminal

WarpTerminal with zsh

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.