Skip to content

fix(mcp): a hung browser tool no longer wedges the workspace bridge - #491

Draft
DavidBabinec wants to merge 1 commit into
mainfrom
fix/mcp-bridge-liveness
Draft

fix(mcp): a hung browser tool no longer wedges the workspace bridge#491
DavidBabinec wants to merge 1 commit into
mainfrom
fix/mcp-bridge-liveness

Conversation

@DavidBabinec

Copy link
Copy Markdown
Contributor

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_context still said siteConnected: true. The reported trigger, a bare <link> through site_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_context now probes each registered bridge with a round-trip the client loop answers itself; a tab silent for 2.5 s is listed under unresponsive instead of reading as connected. callBrowser takes a per-call timeout for that probe.

Verification

bun run build                              # clean
bun run lint                               # clean
bun test                                   # 6847 pass, 0 fail
bunx playwright test mcp-bridge-liveness   # AI-011: 1 passed (real browser, real MCP endpoint)

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.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: site_insert_html with an unsupported element hangs the MCP bridge for the whole session (survives reconnect and tab reload)

1 participant