Repository navigation
perf(browser): bump agent-browser to 0.27.3 to drop its per-command settle sleep - #27192
outof-place wants to merge 1 commit into
Conversation
…ettle sleep agent-browser 0.27.0 sleeps 150 ms in ensure_daemon() on every warm CLI call before reusing the daemon; 0.27.2 removed it (#1432). Every browser command Orca routes through agent-browser (snapshot, click, fill, hover, focus, get, screenshot, exec passthrough...) paid that sleep. The sleep also hid a race in the stale-session reset: `close` on an idle session name spawns a daemon that lingers for its shutdown delay, and without the sleep the next command can reach that daemon and run against its own browser instead of Orca's page. The reset now waits for the closing daemon's pid file to disappear (bounded by the existing 3 s reset timeout, failing closed like a close that never returns). Co-Authored-By: Claude Opus 5.5 <[email protected]>
📝 Walkthrough
Priority: ⬆️ High Severity of issue fixed: Medium Merge Risk: 🔵 Low · up to The dependency update and the stale-session exit wait look sound on supported paths. The only remaining concern is test portability: the two new lifecycle tests hard-code POSIX paths and would fail on Windows. Normalizing those paths is a small follow-up. Pre-merge checks |
|
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
d1396c21-40da-4a78-9678-d0393d200ea1
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (5)
package.jsonsrc/main/browser/agent-browser-bridge-execution.tssrc/main/browser/agent-browser-bridge-session-lifecycle.test.tssrc/main/browser/agent-browser-session-reset.test.tssrc/main/browser/agent-browser-session-reset.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
| existsSyncMock.mockImplementation( | ||
| (...args: unknown[]) => args[0] === '/tmp/orca-ab-test/orca-tab-tab-1.pid' && ++pidChecks <= 2 |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Use platform-normalized PID paths in both mocks. On Windows, join() passes a backslash-normalized path to existsSync, so neither forward-slash comparison matches. The success test fails its ordering assertion, and the timeout test resolves instead of rejecting. (nodejs.org)
src/main/browser/agent-browser-bridge-session-lifecycle.test.ts#L161-L162: compare withjoin('/tmp/orca-ab-test', 'orca-tab-tab-1.pid').src/main/browser/agent-browser-bridge-session-lifecycle.test.ts#L187-L188: use the same normalized comparison.
📍 Affects 1 file
src/main/browser/agent-browser-bridge-session-lifecycle.test.ts#L161-L162(this comment)src/main/browser/agent-browser-bridge-session-lifecycle.test.ts#L187-L188
|
The roughly 150 ms per-command saving is real, but closing this upgrade as not planned after an independent real-binary transition test. A surviving 0.27.0 remote browser with two tabs and an unsaved draft was restarted by the first 0.27.3 command: the active tab changed, the input became empty and live JavaScript state was lost. Reset/scrollbar fixes do not preserve that update transition. This fails our zero-negative-user-facing-trade-off requirement; we will not add a dual-version or native fork subsystem to obtain it. |
ELI5
Most browser commands an agent sends to Orca (snapshot, click, fill, screenshot...) went through a helper program that paused for 150 ms before every command. A newer patch release of that helper removes the pause, so these commands now come back in about 5–40 ms instead of 160–480 ms. Removing the pause also exposed a small race in how Orca resets a helper session, and this PR fixes that too.
What Changed
~0.27.0to~0.27.3and the lockfile follows. This is the same minor line. 0.27.2 removed the unconditional 150 msthread::sleepinensure_daemon()that every warm CLI call paid (Fix agent-facing reliability bugs and cut warm command latency to ~1ms vercel-labs/agent-browser#1432).closeStaleAgentBrowserSessioninagent-browser-bridge-execution.ts).agent-browser --session <name> closeand continued as soon as the CLI exited.<session>.pidfile is gone.waitForAgentBrowserSessionExitinagent-browser-session-reset.tspolls every 25 ms and resolves the socket directory the way agent-browser'sget_socket_dir()does.browser_owner_unavailableerror as a close that never returns.What users see: agent browser automation gets faster per command, as shown under Trade-offs. Nothing else changes.
Why
AGENT_BROWSER_SOCKET_DIR) runscloseon a name that may have no daemon yet.closespawns a daemon, which lingers for its shutdown delay.tests/e2e/browser-embedded-owner-routing.spec.tscatches exactly this: on 0.27.3 without the fix, the snapshot returnsabout:blank, "(empty page)", and the spec fails 2 of 2 runs..pid(with.sock,.versionand.stream) when it exits, on every platform. That makes it the one signal that means "that daemon is gone".close. That re-adds a guessed delay to every reset, and it is still a guess.close --all. It acts only on daemons that already exist and never spawns one. But it closes every session in the socket directory, and an inherited directory can be shared with another profile.Linked Issue
Fixes #27191
Visual Proof
N/A. This is a latency and dependency change with no UI. The measurements below cover the behaviour.
Trade-offs
Setup. macOS 27, Apple M4 Max, Node 24.20.0, on a shared machine with load average 8–20.
node_modules/agent-browser/bin/agent-browser-darwin-arm64was swapped between versions.A. Merge risk and mitigations
waithonours its documented 25 s default and--timeout.typeparses--clearand--delayinstead of typing them.find labelmatchesaria-labelandaria-labelledby. The rest is Windows ARM64 install fallback and Linux release builds pinned to glibc 2.28, which is below Orca's 2.31 floor.src/main/browser,src/main/runtime/orca-runtime-browser*: 219 files, 1975 passed, 2 skipped) and the four browser e2e specs that drive agent-browser and pointer input (13 passed; the owner-routing spec 3 more times with--repeat-each=3).B. User-facing trade-offs, both directions
browser.snapshotbrowser.clickbrowser.hoverbrowser.focusbrowser.fill(3 agent-browser calls)browser.get titlebrowser.screenshotgoto,evaland pointer RPCs don't use agent-browser and are unchanged (goto 14–16 ms both ways).existsSyncpoll that only runs until the closing daemon exits.C. Maintenance cost
.thenin the reset callback that reuses the reset's existing deadline and error.Verdict: free win. About 150 ms comes off every agent-browser-backed command, with no CPU or memory cost. The one race the old sleep covered is now closed explicitly.
Testing
Ran locally on the final branch:
pnpm test src/main/browser src/main/runtime/orca-runtime-browser --maxWorkers=4: 219 files; 1975 passed, 2 skipped.tests/e2e/browser-embedded-owner-routing.spec.ts,browser-pointer-input-dispatch.spec.ts,browser-tab.spec.tsandbrowser-fedcm-fallback.spec.ts(--project electron-headless --workers=2, withORCA_BACKGROUND_LAUNCH=1): 13 passed. On 0.27.3 without the reset fix,browser-embedded-owner-routingfailed 2 of 2 runs.pnpm run tc:nodeORCA_CODE_QUALITY_BASE=upstream/main pnpm run check:code-quality:changedpnpm run check:max-lines-ratchetNot run locally: Windows and Linux, the full
pnpm testandpnpm lint, and packaging. Windows takes the reset path on every new session, so its CI matters most. Its pid-file location comes from the sameget_socket_dir()rule the helper mirrors.AI Disclosure
Implemented with Claude Opus 5.5 via Claude Code: diagnosis, code, tests and measurements. A human (outof-place) directed the work.
Review
Start with
waitForAgentBrowserSessionExitinagent-browser-session-reset.ts, then its single call site incloseStaleAgentBrowserSession.Agent skill upstream boundary
Notes
agent-browser closeitself auto-launches a local browser before closing it. This happens on both versions; I saw it with a stubAGENT_BROWSER_EXECUTABLE_PATH. That is wasted work on the reset path and worth a separate issue.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred). Only the commands listed under Testing ran locally; the rest is left to CI.🤖 Generated with Claude Code