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
server: no SIGTERM handling, MCP stdio (docker) children orphaned on every stop/restart #50780
The v2 server never traps SIGTERM/SIGINT, so Effect scopes (including MCP stdio transports) are never closed on stop/restart/crash. Local docker run MCP servers orphan permanently — --rm doesn't save them since nothing ever stops the container. I accumulated ~95 orphaned postgres-mcp containers from normal restarts alone.
Configure a local MCP server using docker run (e.g. crystaldba/postgres-mcp), open any project using it so the server connects.
docker ps → one container running for the connection.
Restart the server (opencode service restart, systemctl stop, or crash it).
docker ps → the old container is still running; the new server generation spawns a fresh one. Repeat → unbounded pileup (I reached ~95).
Same leak via TUI flow, no restart involved:
Attach a TUI to a running server (opencode --server http://localhost:4096), open a repo with a docker MCP.
docker ps → container running.
Ctrl+C the TUI (session stays server-side by design).
The container keeps running indefinitely — observed persisting 20h+, well past the 60-minute location idle-eviction window, so eviction either never fires for these locations or doesn't tear down the MCP scope.
Expected Behavior
Server shutdown closes MCP scopes gracefully (the stdio transport already implements SIGTERM → 2s grace → SIGKILL in packages/core/src/mcp/stdio.ts), terminating child processes. Likewise, fully-idle locations (no attached clients, no active sessions) should release their MCP processes instead of holding them past the eviction window.
Actual Behavior
No signal handler exists anywhere in the server path (only desktop lifecycle, non-interactive runs, and profilers trap signals). Node dies instantly on SIGTERM; scopes/finalizers never run; docker children are adopted and run forever. Location idle eviction (60 min) only helps live servers, never post-restart orphans — and in the TUI-detach flow the containers outlive the eviction window.
Additional Context
Verified against v2 branch source (2026-09-22): packages/core/src/mcp/index.ts ("Connections remain Location-scoped"), packages/core/src/location-activity.ts (60-min TTL sweeper), packages/core/src/mcp/stdio.ts (graceful close that never gets invoked on shutdown).
Workaround: manually docker stop containers with no live docker run client process.
In particular, #50758 appears to be nearly identical to this report. Please review it and let a maintainer know if your report covers a meaningfully distinct scenario (e.g. the SIGTERM signal handler gap specifically, or the docker --rm interaction) before we decide whether to consolidate.
Thanks for the report. We're tracking the same MCP child-process cleanup problem on service restart in #50758, so I'm closing this as a duplicate. Please follow that issue for updates.
Activity
github-actions commentedon Sep 23, 2026
This issue might be a duplicate of existing issues. Please check:
In particular, #50758 appears to be nearly identical to this report. Please review it and let a maintainer know if your report covers a meaningfully distinct scenario (e.g. the SIGTERM signal handler gap specifically, or the docker
--rminteraction) before we decide whether to consolidate.neriousy commentedon Oct 20, 2026
Thanks for the report. We're tracking the same MCP child-process cleanup problem on service restart in #50758, so I'm closing this as a duplicate. Please follow that issue for updates.