perf: reduce round-trips in browser command hot path#712
Merged
Conversation
1. eval retry delay: 1000ms → 200ms for SPA navigation errors, 500ms for debugger detach. SPA navigations recover within ~100ms, the old 1000ms delay was unnecessarily long. 2. Window creation: replace fixed 200ms sleep with tab-load poll. Listens for chrome.tabs.onUpdated status=complete with 500ms fallback cap. about:blank loads in ~20ms, saving ~180ms. 3. bridge.ts _ensureDaemon: single fetchDaemonStatus() call instead of two sequential calls (isExtensionConnected + isDaemonRunning both called fetchDaemonStatus independently). Saves one HTTP round-trip. 4. goto() post-navigation: coalesce stealth injection + DOM settle into a single exec call. Previously two sequential round-trips (Node→daemon→WS→extension→CDP each). Saves ~60-160ms per goto().
jackwener
added a commit
that referenced
this pull request
Apr 2, 2026
…sDaemonRunning PR #712 refactored _ensureDaemon to use a single fetchDaemonStatus() call instead of separate isDaemonRunning(). The test was still mocking the old function, causing it to fall through to the spawn-daemon path and throw the wrong error message.
2 tasks
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.
Summary
Four targeted optimizations to reduce latency in the browser command hot path:
extension/src/cdp.ts): Reduced retry wait from fixed 1000ms to error-type-aware delays — 200ms for SPA navigation errors (which recover quickly), 500ms for debugger detach errorsextension/src/background.ts): Replaced fixedsetTimeout(200)afterchrome.windows.create()withtabs.onUpdatedlistener that resolves as soon as the tab reportsstatus: 'complete'(500ms fallback cap)src/browser/bridge.ts): Eliminated duplicatefetchDaemonStatus()calls in_ensureDaemon()— now makes one call and branches onextensionConnectedvs daemon-running-but-no-extensionsrc/browser/page.ts): Combined two sequentialsendCommand('exec', ...)round-trips (stealth injection + DOM settle) into a single eval, saving one full Node→daemon→extension→CDP round-trip pergoto()Test plan
tsc --noEmitpasses cleangoto()navigates and settles correctly with coalesced stealth+settle