fix: don't close a shared MCP transport under in-flight sibling calls - #774
Open
bhaveshpatel640 wants to merge 4 commits into
Open
bhaveshpatel640 wants to merge 4 commits into
bhaveshpatel640 wants to merge 4 commits into
Conversation
🦋 Changeset detectedLatest commit: b57abe5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 2 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
bhaveshpatel640
force-pushed
the
AGE-2253
branch
from
September 16, 2026 19:51
d86e954 to
c6e5a95
Compare
bhaveshpatel640
force-pushed
the
AGE-2253
branch
from
September 17, 2026 06:12
4068aa7 to
faf9c05
Compare
bhaveshpatel640
marked this pull request as ready for review
September 17, 2026 06:13
bhaveshpatel640
requested review from
chiragjn,
debajyoti-truefoundry,
heerambavi1998,
sr07asthana and
thesujai
as code owners
September 17, 2026 06:13
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit faf9c05. Configure here.
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
Session-expired MCP retry no longer closes the shared transport while a sibling
callTool/listToolsis still using it. That sibling used to fail with a non-retried close error.AGE-2253 / INFOSEC-15 TF-06
Changes
pendingClose) and close it wheninflighthits 0How was this tested?
pnpm --filter @truefoundry/trueforge-core test -- tests/core/mcp/remoteMcpServer.test.tsChecklist
pnpm build,pnpm test,pnpm typecheck,pnpm lint:ci, andpnpm format:checkpass locallypackages/trueforge-sdk,python/trueforge_sdk,.github/fern/openapi/openapi.json,docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge.env.exampleupdated if configuration or behavior changedNote
Medium Risk
Changes concurrent connection teardown and session-expiry retry in core remote MCP usage; behavior is narrow and covered by new tests, but mistakes could affect parallel tool calls or leak connections.
Overview
Fixes a race where session-expired retry on one concurrent
callTool/listToolswould close the shared remote MCP transport while another call still held it. That sibling then failed with "Connection closed", which is not treated as session-expired, so it was never retried.RemoteMCPnow tracks in-flight operations on a captured connection handle: on expiry it detaches the stale socket intopendingCloseinstead of closing immediately when siblings are active, reconnects and retries once, and closes the deferred socket only wheninflightreaches zero. Stale expiry on an old handle no longer resets a newer live transport, and transportonCloseonly clears connected state when the closed socket is still the active one.Tests simulate a held sibling call plus session expiry on a parallel call, including late expiry on the stale connection after retry.
Reviewed by Cursor Bugbot for commit 1dfd55c. Bugbot is set up for automated code reviews on this repo. Configure here.