fix(mcp): a hung browser tool no longer wedges the workspace bridge - #491
Draft
DavidBabinec wants to merge 1 commit into
Draft
fix(mcp): a hung browser tool no longer wedges the workspace bridge#491DavidBabinec wants to merge 1 commit into
DavidBabinec wants to merge 1 commit into
Conversation
The workspace services relayed tools one at a time, so a tool whose promise never settled blocked every later request on the stream until the tab reloaded, while get_context kept reporting the workspace as connected because it only read the bridge registry. Each relayed tool is now bounded by a 60 s client deadline under the relay's 90 s timeout, and get_context probes each registered bridge with a real round-trip so a stuck tab reads as unresponsive instead of connected.
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.
Fixes #490
The bug
On a hosted install every browser-routed MCP tool failed with "AI chat stream ended before tool result arrived" while
get_contextstill saidsiteConnected: true. The reported trigger, a bare<link>throughsite_insert_html, does not wedge main: the tool returns "no importable elements" in 5 ms and later reads keep working. Main does have a serial workspace loop, so one tool that never settles blocks every later request until the tab reloads, and the connected flag only proved a stream had once been registered.The fix
Each relayed tool (plus its persistence step) is bounded by a 60 s client deadline under the relay's 90 s timeout, so a stuck tool returns an error naming it and the loop keeps serving.
get_contextnow probes each registered bridge with a round-trip the client loop answers itself; a tab silent for 2.5 s is listed underunresponsiveinstead of reading as connected.callBrowsertakes a per-call timeout for that probe.Verification
Notes
The hosted report ran v0.0.18, whose bridge was killed every 120 s regardless of traffic (2306 failed calls in the reconnect gap in a local comparison); 482553c on main already replaced that with an idle lease, so that part needs a release. The new tests were run against the pre-fix source and fail there.