anomalyco / anomalyco/opencode

service: restart leaves stale daemon and duplicated MCP servers running

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

@neriousy is already working on this.

Since Aug 13, 2026.

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

Description

Summary

opencode2 service restart starts a new serve --service daemon without terminating the old one; the stale daemon and its MCP server children keep running, duplicating MCP servers and leaking ~1.5 GB of RAM until manually killed.

Environment

  • opencode version: 0.0.0-next-17403 (next channel, V2 beta)
  • OS: macOS 26.6.1 (Darwin 25.6.0, arm64)
  • Terminal: Apple_Terminal, TERM=xterm-256color
  • Shell: /bin/zsh
  • Install/channel: local binary in ~/.opencode/bin, channel next
  • Active plugins: ~/.config/opencode/plugins.v2/memory.ts (opencode-memory)

Reproduction

  1. Configure local MCP servers (e.g. npx -y @playwright/mcp --browser chromium and npx -y @llmindset/hf-mcp-server) in ~/.config/opencode/opencode.jsonc.
  2. Start a session (spawns the serve --service daemon plus the MCP children).
  3. Run opencode2 service restart (or service stop followed by starting a new session).
  4. Inspect the process tree: the old daemon and its MCP children are still alive next to the new daemon and its own fresh MCP children.

Observed today on macOS arm64:

  • Old daemon PID 79746 opencode2 serve --service, RSS ~700-780 MB, still running after the restart
  • Its children still alive: 2x npm exec @playwright/mcp --browser chromium and 1x npm exec @llmindset/hf-mcp-server, ~85-90 MB each
  • New daemon PID 80086 with its own set of MCP servers
  • Net result: two Playwright MCP instances running concurrently, ~1.5 GB held by the stale tree

Expected Behavior

service restart (and service stop) should terminate the previous daemon's entire process tree, including its MCP children, before starting the new one.

Actual Behavior

The old daemon and all its MCP children keep running after the restart, duplicating MCP servers and leaking memory. The stale tree could only be cleaned manually (kill -9 on the old daemon), and it took its MCP children down with it.

Additional Context

Combined with the daemon's high idle RSS (see related perf issue), opencode2 processes peaked at ~2 GB RSS on a 16 GB MacBook Air. The duplication happened on a single restart, so it looks consistent rather than intermittent. Related: an earlier service restart had also left the previous daemon's MCP servers behind, which is how multiple Playwright instances accumulated.

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.