-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
perfIndicates a performance issue or need for optimizationIndicates a performance issue or need for optimization
Description
Description
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)
Metadata
Metadata
Assignees
Labels
perfIndicates a performance issue or need for optimizationIndicates a performance issue or need for optimization