-
Notifications
You must be signed in to change notification settings - Fork 6.7k
Labels
perfIndicates a performance issue or need for optimizationIndicates a performance issue or need for optimization
Description
Problem
When MCP OAuth flows are initiated, transports are stored in pendingOAuthTransports Map. These transports are never closed when:
- OAuth retry - A new transport is created for the same server, orphaning the previous one
- OAuth cancellation -
removeAuth()deletes the map entry but doesn't close the transport - OAuth timeout - Incomplete flows leave open transports
Additionally, when the main OpenCode process terminates, spawned MCP server processes may continue running as orphans.
Code Location
packages/opencode/src/mcp/index.ts
Impact
- Open connections accumulate over OAuth retries
- Orphaned MCP server processes after OpenCode exits
- Memory growth in long-running sessions
Relates to #5363
Expected Behavior
- Old transports should be closed before creating new ones
removeAuth()should close transport before deletion- Process exit should clean up all MCP clients
Metadata
Metadata
Assignees
Labels
perfIndicates a performance issue or need for optimizationIndicates a performance issue or need for optimization