fix(server): keep preview browser connected after operation timeouts #17693
main fromrefs/pull/17693/head·merged by juliusmarminge View on GitHubProblem#
A normal preview navigation or wait timeout could disconnect the server-owned browser. The broker used the same deadline as the page operation, so the browser's timeout response arrived after the broker had evicted it. In the observed failures, replies arrived 3 ms and 127 ms after eviction, and subsequent calls returned misleading desktop-host instructions.
Change#
Give the browser one second to return its response after the operation budget. The page timeout and the 500 ms background status budget stay the same. Unresponsive hosts still get evicted, and actions are never replayed.
Update unavailable-browser and recording-failure messages for the server-owned browser.
Scope and approval#
Small, focused fix for a reproduced failure in the existing preview timeout and recovery path, requested by a maintainer.
Verification#
- The existing host-retention test now delays the browser's timeout response until 50 ms after its operation budget, then checks that the timeout reaches the caller and the next status call succeeds. Removing the response allowance makes this test fail.
- Existing tests cover hung-host eviction, rejection of queued actions, and the unchanged 500 ms background status deadline.
- 126 focused broker, MCP HTTP, preview-handler, server-browser and contract tests passed. Targeted lint and formatting passed. Server typecheck passed.
CI tests, build, and typecheck pass on the current head. Lint fails on the unchanged base-branch focus-ring error, outside this PR’s diff.
A genuinely unresponsive host takes up to one extra second to be detected.
Implemented with GPT-6.1-Sol in Codex. Tests minimized by Claude Opus 5.5 in Claude Code; implementation independently checked by Claude Fable 5.1 in Claude Code. Final whole-PR adversarial reviews by Claude Opus 5.5 in Claude Code and GPT-6.1-Sol in Codex found no actionable issues on 7a88459.
Fixes #12898
- 1
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:S
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
-
-
⚙️ Run configuration
-
-
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
a30f5960-3eb1-4cf8-a66d-9757b66fc3c3
-
-
📥 Commits
-
-
-
Reviewing files that changed from the base of the PR and between 6974acc367ac4afc3fdbd534ead8c5a6bab020c4 and 7a8845902024b16faa27b66687f987fb91c4e37c.
-
-
📒 Files selected for processing (1)
-
-
-
apps/server/src/mcp/McpHttpServer.test.ts
-
-
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
-
-
-
📝 Walkthrough
-
📝 Walkthrough
-
-
📝 Walkthrough
-
-
-
Walkthrough#
The broker adds a 1,000 ms response grace period for requests that update the current tab. Requests with
updateCurrentTab === falseretain the original timeout. Preview automation error messages and related test expectations are updated.Changes#
Preview automation
Layer / File(s) Summary Broker response window
apps/server/src/mcp/PreviewAutomationBroker.ts,apps/server/src/mcp/PreviewAutomationBroker.test.tsThe broker allows an additional 1,000 ms for host responses unless updateCurrentTabisfalse. Tests cover delayed remote timeouts, follow-up status requests, and action eviction.Error messages and test expectations
packages/contracts/src/previewAutomation.ts,apps/server/src/mcp/PreviewAutomationBroker.test.ts,apps/server/src/mcp/McpHttpServer.test.tsThe no-host message gives a retry sequence. Recording error messages remove the saved-copy claim, and the oversized-recording message advises making a shorter recording. Tests check the updated messages. Priority: ➖ Normal
Estimated code review effort: 2 (Simple) | ~15 minutes
Change: Bug fix · Severity of issue fixed: Medium
Sequence Diagram(s)#
sequenceDiagram participant Caller as MCP caller participant Broker as PreviewAutomationBroker participant Host as Preview host Caller->>Broker: Invoke waitFor with a 1,000 ms timeout Broker->>Host: Deliver request Host-->>Broker: Return remote timeout after timeout plus 50 ms Broker-->>Caller: Return remote timeout error Caller->>Broker: Invoke status Broker->>Host: Deliver status request Host-->>Broker: Return status Broker-->>Caller: Return statusSuggested reviewers:
maria-rcks
-
-
-
-
-
Merge Risk: ⚪ Minimal · up to
7a884The change preserves the desktop-backed preview session when an operation timeout response arrives within the added second. No actionable merge risk is established by the supplied changes.
Pre-merge checks |
4-
✅ Passed checks (4 passed)
-
Check name Status Explanation Linked Issues check Issue #12898requires an operation-levelpreview_wait_fortimeout to reach the caller without evicting the host, while preserving later requests on the pinned session. The broker now allows 1,000 ms…Out of Scope Changes check The changed broker behavior, regression tests, and updated unavailable-browser and recording-failure guidance remain within the stated preview-browser recovery scope. The summary shows no unrelated fe… Title check The title clearly and concisely describes the primary server-side fix: keeping the preview browser connected after operation timeouts. Description check The description covers the problem, change, scope, verification results, known limitations, issue reference, and tool usage. The scope section does not include a direct link to maintainer approval, bu…
-
✨ Finishing Touches 💡 1
-
-
-
📝 Generate docstrings
-
-
-
-
-
-
- Commit to this branch
- Create a new PR
-
-
-
-
-
🧪 Generate unit tests (beta)
-
-
-
- Commit to this branch
- Create a new PR
-
-
-
-
🛠️ Fix failing CI checks 💡
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.-
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
ℹ️ The exact PR base did not have a successful artifact. Baseline uses the latest successful
mainmeasurement shown below.Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅ Codex Live turn messages 2 2 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅ Claude Live turn messages 2 2 0 (0.0%) 8 ✅ Baseline:
c1f21e5· PR result:7a88459· Source CI: failureScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
juliusmarminge merged this5c715c6
juliusmarminge closed this
Sign in to join this conversation.
Approvability#
Verdict: Not approved
Macroscope's review found this PR not approvable — This is a small, focused timeout-recovery fix with targeted tests, but it changes the effective default response deadline for ordinary preview operations by adding a 1,000 ms grace period. That default runtime change warrants human review.
Notes:
- No code objects were reviewed. Approvability was decided on eligibility alone.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).