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
Memory leak: MCP clients not closed before reassignment #8257
When MCP clients are reassigned in MCP.add() or during OAuth finishAuth(), the existing client at that key is silently overwritten without being closed first.
Impact
Open connections/sockets are orphaned
Active event listeners accumulate
Resources are never released
Contributes to memory growth in long-running sessions
Location
packages/opencode/src/mcp/index.ts - two locations where s.clients[name] = result.mcpClient overwrites existing clients
Reproduction
Connect to an MCP server
Reconnect or complete OAuth flow
Previous client is leaked
Related
Part of #3013 (general memory issues)
Related to #7261 (MCP orphan processes)
Activity
github-actions commentedon Jan 13, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if none of these address your specific case.