anomalyco / anomalyco/opencode
service: restart leaves stale daemon and duplicated MCP servers running
@neriousy is already working on this.
Since Aug 13, 2026.
- 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
- Configure local MCP servers (e.g.
npx -y @playwright/mcp --browser chromiumandnpx -y @llmindset/hf-mcp-server) in~/.config/opencode/opencode.jsonc. - Start a session (spawns the
serve --servicedaemon plus the MCP children). - Run
opencode2 service restart(orservice stopfollowed by starting a new session). - 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 chromiumand 1xnpm 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.