fix(browser): recover stale page before evaluate - #2222
Conversation
|
@jackwener This is ready for review. The failure was reproduced from a retained Browser Bridge trace without additional site calls: navigation returned a target that became stale before the adapter's first Focused browser tests, typecheck, and build are green; the PR also keeps explicitly selected tabs fail-closed when no trustworthy URL is available. |
|
Canary follow-up: the first patch covered stale identities during The sequence was:
The trace had no failed network requests, and the stack pointed to Validation after the update:
|
|
Second isolated canary on
This confirms the stale identity path addressed here was crossed in the real adapter flow. The later failure has a different safety boundary: generic |
Summary
Page.evaluate()Root cause
The Browser Bridge can return a page identity from navigation that is evicted before the adapter's next evaluate call. The extension rejects that identity in
resolveTabId()before any page code runs, butPage.evaluate()only retried target-navigation errors and kept resending the stale target. Adapters then surfaced a generic command execution failure even though the failure was recoverable at the page lifecycle boundary.Page.goto()already had equivalent stale-identity recovery for later navigations. This change closes the missing evaluate path without adding adapter-specific retry logic.Impact
Cookie-backed adapters can recover when a page target becomes stale between navigation and their first API evaluation. Other evaluate failures remain unchanged, and caller-selected tabs without a known URL are never replaced implicitly.
Validation
npm run typechecknpm run buildnpx vitest run --project unit src/browser— 28 files, 427 tests passedThe full sandbox suite reached 6,546 passing tests; its remaining 40 failures were unrelated
EPERMwrites to the real user home, so they were not retried against live user configuration.