fix(mcp): Fix memory leaks in OAuth transport and process cleanup - #9145
sauerdaniel wants to merge 2 commits into
Conversation
|
Thanks for your contribution! This PR doesn't have a linked issue. All PRs must reference an existing issue. Please:
See CONTRIBUTING.md for details. |
|
The following comment was made by an LLM, it may be inaccurate: Based on my search, I found one potentially related PR that addresses similar concerns: Related PR Found:
The searches did not reveal any other open PRs that directly duplicate the work in PR #9145. The current PR (#9145) appears to be the first to comprehensively address both OAuth transport leaks and orphaned process cleanup together through the mechanisms described. |
00637c0 to
71e0ba2
Compare
f1ae801 to
08fa7f7
Compare
58b8e23 to
f60e197
Compare
d782b49 to
55cef01
Compare
Close existing client before reassigning to prevent transport layer memory leaks. Add proper cleanup in MCP client lifecycle.
…ent orphan processes
55cef01 to
847e0f7
Compare
|
Automated PR Cleanup Thank you for contributing to opencode. Due to the high volume of PRs from users and AI agents, we periodically close older PRs using automated criteria so maintainers can focus review time on the most active and community-supported contributions. This PR was closed because it matched the following cleanup criteria:
PRs created within the last month are not affected by this cleanup. If you believe this PR was closed incorrectly, or if you are still actively working on it, please leave a comment explaining why it should be reopened. A maintainer can review and reopen it if appropriate. Thanks again for taking the time to contribute. |
Summary
Fix memory leaks in MCP OAuth transport management and add process exit cleanup to prevent orphaned MCP server processes.
Fixes #9153
Relates to #5363
Problem
removeAuth()deletes the map entry without closing the transport.Solution
Transport Cleanup (
mcp/index.ts)closeTransport()helper that safely calls.close()on a transportsetPendingOAuthTransport()that closes old transports before replacing themremoveAuth()before deleting the map entryProcess Exit Cleanup (
index.ts)SIGINT/SIGTERMhandlers that callInstance.disposeAll()before exitfinallyblock for normal exit pathscleanupDoneflagTesting
bun turbo typecheck)AI-Assisted
Yes