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 — Bug: MCP servers spawn duplicate processes per session — 1 project = 8+ instances, 2+ projects = crash · Issue #29939 · anomalyco/opencode

Bug: MCP servers spawn duplicate processes per session — 1 project = 8+ instances, 2+ projects = crash #29939

New issue
Copy link
New issue
Copy link
Closed as not planned
Closed as not planned
Bug: MCP servers spawn duplicate processes per session — 1 project = 8+ instances, 2+ projects = crash#29939
Copy link
Assignees
nexxeln

Description

@gabriel-ferraresi
gabriel-ferraresi
opened on May 29, 2026
Issue body actions

Pre-flight Checks

  • I have searched existing issues and this is not a duplicate
  • I understand this issue needs status:approved before a PR can be opened

Bug Description

OpenCode spawns independent MCP server processes for each session/project. With 5 MCP servers configured (context7, chrome-devtools, nimgen, grep_app, pencil), a single Desktop session creates 24 node processes consuming 1.8GB RAM. With 2+ projects active, this doubles to 48 processes / 3.6GB, causing system-wide crashes.

Steps to Reproduce

  1. Configure 5 MCP servers in \opencode.jsonc\
  2. Open 1 project in OpenCode Desktop → observe 24 MCP node processes
  3. Open a 2nd project → observe 48 MCP node processes
  4. System RAM exhausts → ReadableStream controller crash → server goes red/black

Expected Behavior

MCP servers should be shared across sessions (singleton pattern). One context7 process should serve all sessions, not one per session.

Actual Behavior

Each session spawns its own set of MCP servers. No deduplication or scope sharing exists.

Evidence

\\

1 project active:

MCP context7: 8 processes × ~70MB = 552MB
MCP chrome-devtools: 8 processes × ~105MB = 828MB
MCP nimgen: 8 processes × ~60MB = 474MB
Total MCP: 24 processes = 1,888MB (1.8GB)

After cleanup (keeping 2 per type):

6 processes = 314MB — 83% reduction
\\

Operating System

Windows 11

Agent / Client

OpenCode Desktop v1.15.11

Relevant Logs

\\

server.log — every session shows:

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 exit listeners added to [process]. MaxListeners is 10.
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGINT listeners added to [process]. MaxListeners is 10.
MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 11 SIGTERM listeners added to [process]. MaxListeners is 10.
\\

Additional Context

  • Related to fix(mcp): MCP server loses connection mid-session causing intermittent failures #23997 (MCP connection drops) — the duplication is likely the root cause
  • The MaxListenersExceededWarning is a direct consequence: each MCP instance adds exit/SIGINT/SIGTERM listeners
  • Workaround: cleanup script that kills duplicate MCP processes, keeping only 2 per type
  • Setting \NODE_OPTIONS=--max-listeners=20\ delays but does not fix the issue

Activity

  1. github-actions commented on May 29, 2026

    @github-actions
    github-actionsBot
    on May 29, 2026 – with GitHub Actions
    Contributor
    More actions

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

    • MCP servers spawned 8-10x per instance on Windows, consuming ~3.5 GB RAM on startup #26336: MCP servers spawned 8-10x per instance on Windows, consuming ~3.5 GB RAM — same root cause (no process deduplication/sharing across sessions), same OS, very similar symptoms and evidence
    • Local stdio MCP servers leak processes on disconnect / replace / rollback #26714: Local stdio MCP servers leak processes on disconnect/replace/rollback — related process accumulation issue
    • 桌面版opencode启动会启动两个mcp的npm进程 #16320: Desktop opencode spawns two MCP npm processes on startup — earlier report of the same duplicate-spawn behavior
  2. github-actions
    assigned
    nexxeln
    on May 29, 2026
  3. gabriel-ferraresi commented on May 29, 2026

    @gabriel-ferraresi
    gabriel-ferraresi
    on May 29, 2026
    Author
    More actions

    Cross-referencing existing issues

    The bot flagged #26336, #26714, and #16320 as potential duplicates. Here's how this issue differs:

    • MCP servers spawned 8-10x per instance on Windows, consuming ~3.5 GB RAM on startup #26336 reports the same symptom (8-10x MCP spawning, 3.5GB RAM) but without quantitative process-level data or a workaround
    • Local stdio MCP servers leak processes on disconnect / replace / rollback #26714 focuses on process leak on disconnect/rollback — a different trigger but same underlying problem
    • 桌面版opencode启动会启动两个mcp的npm进程 #16320 is an earlier report of 2x spawning on startup

    This issue provides:

    1. Exact process counts and RAM measurements: 24 MCP processes = 1,888MB for a single project
    2. A working cleanup script that reduces 24→6 processes (1,888MB→314MB, 83% reduction): keeps the 2 oldest PIDs per MCP type, kills the rest
    3. The causal chain: MCP duplication → MaxListenersExceededWarning (11 listeners > limit 10) → ReadableStream controller crash → PTY failure → server red/green cycling
    4. NODE_OPTIONS workaround: --max-listeners=20 --max-old-space-size=4096\ delays the crash

    If this is consolidated into #26336, the quantitative data and cleanup script from this issue should be preserved.

  4. m13v commented on May 30, 2026

    @m13v
    m13v
    on May 30, 2026
    More actions

    this is the stdio-binds-to-client-lifecycle pattern, and every multi-session MCP host hits it. stdio servers have no notion of who's connected, so the host's only lever is spawn-a-child-per-session and kill it on session exit. N sessions across M projects = N×M process trees, and that MaxListenersExceededWarning is just each spawn re-registering exit/SIGINT/SIGTERM on the same parent. capping at 2-per-type treats the symptom. the structural fix is a broker owning one long-lived process per server config and multiplexing sessions over it with refcounted shutdown. http+sse sidesteps it entirely because connection and process are already separate.

  5. github-actions commented on Jul 29, 2026

    @github-actions
    github-actionsBot
    on Jul 29, 2026 – with GitHub Actions
    Contributor
    More actions

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

  6. github-actions
    closed this as not plannedon Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @nexxeln
    nexxeln

Labels

No labels
No labels

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.