Skip to content

plugins: hot reload makes the server unavailable #42898

Closed as not planned
Closed as not planned

Description

@benknab

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

Activity

  1. github-actions commented on Oct 16, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions