GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — opencode run: MCP child processes not terminated on exit (orphan leak) · Issue #15808 · anomalyco/opencode

opencode run: MCP child processes not terminated on exit (orphan leak) #15808

New issue
Copy link
New issue
Copy link
Closed
Closed
opencode run: MCP child processes not terminated on exit (orphan leak)#15808
Copy link
Assignees
thdxr
Labels
coreAnything pertaining to core functionality of the application (opencode server stuff)

Description

@the3asic
the3asic
opened on Mar 3, 2026
Issue body actions

Summary

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

  1. Configure MCP servers in opencode.json (e.g., mcp-searxng)
  2. Run opencode run "any prompt" — MCP servers are spawned as child processes
  3. After opencode run completes and exits, check: ps -eo pid,ppid,args | grep mcp-searxng
  4. 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

Environment

  • OpenCode version: 1.3.0
  • OS: Ubuntu 20.04 (ARM64, Oracle Cloud)
  • MCP servers configured: searxng, tavily, sequential-thinking, zhipu-vision, github-search, websearch

Expected Behavior

opencode run should send SIGTERM to all spawned MCP child processes before exiting (or use a process group so they all terminate together).

Current Workaround

Cron script that periodically kills orphaned MCP processes (PPID=1):

#!/usr/bin/env bash
MCP_PATTERNS="mcp-searxng|mcp-tavily|sequential-thinking|github-search|zhipu-vision|websearch"
while IFS= read -r line; do
    pid=$(echo "$line" | awk '{print $1}')
    ppid=$(echo "$line" | awk '{print $2}')
    [ "$ppid" = "1" ] && kill "$pid" 2>/dev/null
done < <(ps -eo pid,ppid,args | grep -E "$MCP_PATTERNS" | grep -v grep)

Activity

  1. github-actions
    assigned
    thdxr
    on Mar 3, 2026
  2. github-actions
    added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Mar 3, 2026
  3. github-actions commented on Mar 3, 2026

    @github-actions
    github-actionsBot
    on Mar 3, 2026 – with GitHub Actions
    Contributor
    More actions

    This issue might be a duplicate of existing issues. Please check:

    • [Bug] MCP processes not terminated after session ends #6633: MCP processes not terminated after session ends (same core problem, now closed - may have been prematurely closed or not fully fixed)
    • v1.1.6 still has memory bloat - heap not released + MCP orphan processes #7261: MCP orphan processes accumulating across sessions (includes the same MCP orphan subprocess issue)
    • Memory leak: serve and web commands leak child processes on exit; SSE heartbeat interval leaks on server-initiated close #14091: serve and web commands leak child processes on exit; no graceful shutdown / SIGTERM handling (same root cause - no cleanup on exit)
    • Missing SIGHUP handler causes orphaned processes to leak ~4.7 GB each after terminal death #14504: Missing SIGHUP handler causes orphaned processes to leak (related orphan process / missing signal handler issue)
    • Memory Leak: Orphaned processes when terminal closes without explicit exit #10563: Orphaned processes when terminal closes without explicit exit (similar orphan process accumulation)

    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.

  4. nexxeln commented on Mar 3, 2026

    @nexxeln
    nexxeln
    on Mar 3, 2026
    Contributor
    More actions

    fixed in #15516

  5. nexxeln
    closed this as completedon Mar 3, 2026
  6. yangshuai0711
    marked Local stdio MCP servers leak processes on disconnect / replace / rollback #26714 as a duplicate of this issue on May 10, 2026
  7. yangshuai0711
    unmarked Local stdio MCP servers leak processes on disconnect / replace / rollback #26714 as a duplicate of this issue on May 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @thdxr
    thdxr

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402775 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.