fix(opencode): reconnect closed remote MCP clients#33724
Open
rekram1-node wants to merge 2 commits into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
onclosewhile retaining the existing publicfailedstatusRelated issues
Tests
bun test test/mcp/reconnect.test.ts --timeout 30000bun test test/mcp/lifecycle.test.ts --timeout 30000bun test test/mcp/session-recovery.test.ts --timeout 30000bun typecheckinpackages/opencode(run once during implementation; not repeated after the resource constraint update)bunx prettier --check src/mcp/index.ts test/mcp/reconnect.test.ts test/fixture/mcp-reconnect-server.tsThe new tests use a real loopback MCP endpoint in a child process with IPC/HTTP readiness signals, no mocks or fixed sleeps. They prove a single replacement initialization, no replay of an ambiguously failed call, a later request using the replacement, and intentional disconnect fencing a late reconnect.
Residual design
This first PR intentionally reacts only to definitive
oncloseand does not classify arbitrary request errors or replay requests. Ambiguous tool failures remain failures; recovery is available to future requests after the transport definitively closes.