You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
opencode run: MCP child processes not terminated on exit (orphan leak) #15808
opencode run spawns MCP server processes (e.g., mcp-searxng, mcp-tavily, sequential-thinking, etc.) but does not terminate them when the run session exits. These processes get reparented to PID 1 and persist indefinitely, causing significant memory leaks over time.
Reproduction
Configure MCP servers in opencode.json (e.g., mcp-searxng)
Run opencode run "any prompt" — MCP servers are spawned as child processes
After opencode run completes and exits, check: ps -eo pid,ppid,args | grep mcp-searxng
The MCP processes are still alive with PPID=1 (orphaned)
Impact
In a cron-based setup (e.g., heartbeat scripts calling opencode run every 30 minutes), orphaned MCP processes accumulate rapidly:
Each mcp-searxng process consumes ~61MB RSS
~90 opencode run invocations/day = ~5.5GB/day leaked
Observed: 301 orphaned mcp-searxng processes consuming ~18GB before manual cleanup
If your issue is specifically about the opencode run (non-interactive/headless) command not cleaning up MCP subprocesses, and none of the above cover that exact path, please clarify that distinction so maintainers can triage accordingly.
Activity
github-actions commentedon Mar 3, 2026
This issue might be a duplicate of existing issues. Please check:
serveandwebcommands leak child processes on exit; SSE heartbeat interval leaks on server-initiated close #14091:serveandwebcommands leak child processes on exit; no graceful shutdown / SIGTERM handling (same root cause - no cleanup on exit)If your issue is specifically about the
opencode run(non-interactive/headless) command not cleaning up MCP subprocesses, and none of the above cover that exact path, please clarify that distinction so maintainers can triage accordingly.nexxeln commentedon Mar 3, 2026
fixed in #15516