Repository navigation
Conversation
…e while calls are pending
The editor runs relayed MCP tools strictly one at a time, but the server
pushed a whole batch at once. Every call's 90s timeout started at push time,
so calls queued behind slow ones (render snapshots, a background tab) timed
out before the editor reached them. The 120s idle lease was only re-armed by
pushes, so a batch whose serial execution outlasted it closed the stream
mid-batch: the in-flight call was rejected ("closed with 1 pending tool
result(s)") and the editor's late result POST got a 404.
- createBridge gains an opt-in `serial` option: the next request is emitted
only after the previous one settles, and its timeout starts on emit.
Queued calls still reject on abort/destroy without being emitted. The chat
bridge is unchanged.
- The editor bridge uses serial delivery, and its idle lease re-arms instead
of closing while any call is pending. Each pending call is bounded by the
per-call timeout, so an orphaned stream still drains and closes.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ngocht
marked this pull request as ready for review
October 14, 2026 18:12
This branch has not been deployed
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
MCP edits routed to the live editor were slow and intermittently failed in production.
The editor executes relayed tools strictly one at a time (
useMcpWorkspaceBridgeawaits each tool and its result POST before reading the next line), but the server pushed a whole batch at once:[ai/transport] bridge … closed with 1 pending tool result(s)., seen three times in one hour on a production site) and the editor's late result POST got a 404 from/admin/api/ai/tool-result.Changes:
createBridgegains an opt-inserialoption. The next request is emitted only after the previous one settles, and its timeout starts on emit. Queued calls still reject on abort/destroy without being emitted. The chat bridge is unchanged.docs/features/mcp-connectors.mddescribes the new delivery and lease behavior.Impact: no throughput loss (the editor was already serial); queued MCP calls no longer time out spuriously, and batches are no longer cut by the lease.
Verification
bun run build— rantsc -p tsconfig.app.jsonandtsc -p tsconfig.node.json(clean)bun test— ranbun test src/__tests__/ai/ server/ai/: 277 pass. New tests: serial ordering, timeout starts on emit, timeout releases the slot, destroy/abort reject queued calls unsent, a batch outlasting the lease survives, no recycle while a call is pending.bun run lint— eslint on the changed files (clean)Checklist
🤖 Generated with Claude Code