Skip to content

fix(runtime): keep WSL browser CLI RPCs alive - #18404

Open
Jinwoo-H wants to merge 1 commit into
mainfrom
sep03-sta6407-wsl-browser-runtime-repro-local
Open

Jinwoo-H wants to merge 1 commit into
mainfrom
sep03-sta6407-wsl-browser-runtime-repro-local

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The WSL CLI reaches a Windows Orca host through the local runtime RPC transport (a Windows named pipe). browser.snapshot, browser.screenshot, and browser.wait can block in agent-browser startup/paint/condition waits, but the runtime long-poll classifier treated them as short RPCs. The 30s socket/named-pipe idle timer could therefore close a healthy request before the browser helper replied; the CLI surfaced runtime_unavailable. eval, click, and tab commands remain on the short path.

This patch classifies those three browser methods as the existing wait long-poll class. That enables the existing keepalive frames and abort/slot accounting for both Unix sockets and Windows named pipes. No new wire fields, opcodes, retries, polling, or fallback routing are introduced.

Deterministic evidence

  • Oracle: src/main/runtime/runtime-rpc-long-poll-transport.test.ts
  • Classifier assertions cover the affected methods (browser.snapshot, browser.screenshot, browser.wait) and controls (browser.eval, browser.click, browser.tabSwitch). On the base revision those new assertions are red because the methods classify as short RPCs.
  • A real newline-framed local RPC session delays browser.snapshot for 120ms, observes >=2 keepalives, and receives exactly one terminal response on the candidate.
  • Focused result: pnpm test src/main/runtime/runtime-rpc-long-poll-transport.test.ts src/cli/browser.test.ts — 57 passed.
  • Additional result: 49 tests passed across local long-poll, WebSocket long-poll, remote client, and envelope suites; 38 browser bridge/lifecycle tests passed.
  • pnpm tc:node passed.
  • pnpm run check:code-quality:changed passed with 0 new findings.

Compatibility and limits

The keepalive frame is already part of the existing RPC envelope and is understood by current/legacy clients; this changes only host-side classification. The existing long-poll cap still bounds concurrency and returns runtime_busy under saturation.

This workspace is macOS. Windows 2, WSL2, ConPTY, and the physical Windows named-pipe path were not available, so no physical Windows/WSL reproduction is claimed. The oracle exercises the same classifier and real local framed transport used by that path, but it does not prove WSL interop, PowerShell argv forwarding, or Windows kernel named-pipe behavior. A >30s end-to-end timeout was not run in CI because it would make the regression suite unnecessarily slow; the causal boundary is the host idle timer plus the missing classifier entry.

Linear was not mutated; the session's orca-ide Linear CLI was unavailable.

@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The runtime now classifies browser.snapshot, browser.screenshot, and browser.wait as long-poll requests. Tests confirm that browser.eval, browser.click, and browser.tabSwitch remain short RPCs. A socket transport test confirms that delayed snapshot requests emit keepalive frames and return one terminal response with the browser page ID and snapshot.

Merge Risk: 🔵 Low · up to 70448

Browser snapshot, screenshot, and wait requests now remain connected through the long-poll path. The implementation is covered for routing and keepalives, with a low residual risk that a terminal snapshot response regression would not be caught by the new transport test.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the problem, change, rationale, testing, compatibility, and platform limits. However, it does not follow the required template and omits the required Linked Issue, Visual Proo… Restructure the description using the repository template. Add a linked issue after “Fixes #”. Add visual proof or write exactly “N/A” with a reason if no visual or interaction change applies. Add the required Testing, Review, Agent skill u…
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: keeping runtime browser CLI RPCs alive.
Full details: Description check

Explanation

The description explains the problem, change, rationale, testing, compatibility, and platform limits. However, it does not follow the required template and omits the required Linked Issue, Visual Proof or an explicit N/A statement, Testing checklist, Review, Agent skill upstream boundary, Notes, and Checklist sections.

Resolution

Restructure the description using the repository template. Add a linked issue after “Fixes #”. Add visual proof or write exactly “N/A” with a reason if no visual or interaction change applies. Add the required Testing, Review, Agent skill upstream boundary, Notes, and Checklist sections, and mark each applicable item.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 98ae6b27-d9df-48c7-abb3-b733b805ef8d

📥 Commits

Reviewing files that changed from the base of the PR and between f70f580 and 70448ac.

📒 Files selected for processing (2)
  • src/main/runtime/runtime-rpc-long-poll-transport.test.ts
  • src/main/runtime/runtime-rpc/runtime-rpc-long-poll.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review.

expect(
session.frames.filter((frame) => frame._keepalive === true).length
).toBeGreaterThanOrEqual(2)
expect(session.frames.filter((frame) => frame.ok !== undefined)).toHaveLength(1)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Assert the terminal response payload.

The current assertion only checks that one frame has an ok field. It does not verify ok === true, browserPageId, or snapshot. A transport regression that drops or rewrites the result can pass this test.

Suggested assertion
-        expect(session.frames.filter((frame) => frame.ok !== undefined)).toHaveLength(1)
+        const terminalFrames = session.frames.filter((frame) => frame._keepalive !== true)
+        expect(terminalFrames).toHaveLength(1)
+        expect(terminalFrames[0]).toMatchObject({
+          ok: true,
+          result: { browserPageId: 'page-1', snapshot: 'tree' }
+        })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
expect(session.frames.filter((frame) => frame.ok !== undefined)).toHaveLength(1)
const terminalFrames = session.frames.filter((frame) => frame._keepalive !== true)
expect(terminalFrames).toHaveLength(1)
expect(terminalFrames[0]).toMatchObject({
ok: true,
result: { browserPageId: 'page-1', snapshot: 'tree' }
})

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one scope question inline.

Reviewed changes

  • browser.snapshot / browser.screenshot / browser.wait classified as wait long-polls — classifyRuntimeLongPoll now returns 'wait' for the three browser methods that block on helper startup/paint/condition waits, arming the existing keepalive frames so the 30s socket/named-pipe idle timer no longer tears down a healthy in-flight WSL CLI request.
  • Regression coverage — a classifier it.each oracle pins the three methods to 'wait' (and browser.eval/browser.click/browser.tabSwitch to the short path), plus a real newline-framed session test that blocks the dispatcher for 120ms and asserts ≥2 keepalives with exactly one terminal frame.

The change is correctly scoped: keepalive arming (context?.startKeepalive()), slot accounting, and the (unused-by-browser-handlers) abort signal are all shared wiring already exercised by terminal.wait and orchestration.check --wait. Slot contention under saturation returns runtime_busy, which the body acknowledges.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

if (
request.method === 'browser.snapshot' ||
request.method === 'browser.screenshot' ||
request.method === 'browser.wait'

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

browser.goto and browser.reload share this same exposure: the CLI already grants them a 60s timeout (src/cli/handlers/browser-nav.ts) because navigation waits for network idle past the 15s default, and the embedded bridge's navigation budget alone is 30s (EMBEDDED_NAVIGATION_TIMEOUT_MS) — so a cold goto still risks the 30s idle teardown this PR fixes. Worth confirming whether they should join this set or are deliberately out of scope for the STA-6407 repro.

@lumatic2

Copy link
Copy Markdown

Native-Windows evidence that this PR covers more than WSL (Orca 1.4.215, 2026-09-27, native orca.exe from Git Bash, no WSL).

The bundled helper is still agent-browser 0.27.0 (resources/agent-browser-win32-x64.exe --version), so the cold-start stall from vercel-labs/agent-browser#1407 is still present in 1.4.215. Every new tab hits it:

orca tab create --url http://localhost:8000/ui/ --json                 # ok, 0.7s
orca wait --text "<text on page>" --page <id> --json                   # 30.2s -> runtime_unavailable, _meta.runtimeId: null
orca screenshot --page <id> --json                                     # 30.2s -> runtime_unavailable
  • Reproduced on 3 of 3 fresh tabs. On a tab that had already been used, the same wait/screenshot returned in 0.4s.
  • It is not page-specific. A three.js/WebGL app and https://example.com/ behave the same.
  • orca eval on the same fresh tab returns in 0.2s, consistent with eval staying on the short path.
  • tab switch --page <id> before the first helper-backed call did not help (2 of 2 fresh tabs still failed at 30.2s).

Timeline on one fresh tab. It shows the request is healthy but slow, which is what this keepalive change targets:

t (from first call) command result
0s snapshot 30.2s -> runtime_unavailable
~35s screenshot 30.2s -> runtime_unavailable (queued behind the first)
~75s screenshot ok after 15.8s, so it completed at ~90s, matching the helper's 90s internal timeout
~106s screenshot ok, 1.5s

So on native Windows the 30s named-pipe idle close is what turns a slow-but-successful helper call into runtime_unavailable, and later calls to the same page keep failing until the inner call drains. Classifying browser.snapshot / screenshot / wait as long-poll should turn the first call into a ~90s success instead of a transport error. The root fix is still the agent-browser side (vercel-labs/agent-browser#1781), followed by a helper bump here.

Related: #18093

This branch has not been deployed

No deployments
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.

2 participants