-
-
Notifications
You must be signed in to change notification settings - Fork 52.7k
Description
Bug
When using the Chrome extension relay (profile=chrome) to snapshot a page that performs an OAuth redirect chain (e.g., Clerk auth → provider → callback → app), the CDP session becomes stale and subsequent snapshots fail silently or timeout.
Reproduction
- Start extension relay, attach a tab
- Navigate to a page that triggers OAuth (e.g., a Clerk
<SignIn>component) - The page redirects: app → clerk.example.com → provider → callback → app
- Attempt
browser.snapshot()— fails with stale DOM or timeout - Fresh snapshot with updated
targetIdalso fails — relay tracks the tab correctly viaTarget.targetInfoChanged, but the Playwright CDP session is broken
Root Cause
The relay correctly handles Target.targetInfoChanged events to update cached tab metadata (URL, title). However:
-
Playwright CDP session staleness: After multiple rapid navigations, Playwright's internal CDP session for the page can become disconnected from the actual page state. The relay proxies commands, but Playwright's page object may hold stale frame references.
-
No reconnection mechanism: When
findPageByTargetIdis called after navigation, it can find the page by targetId (relay updated metadata), but the page's CDP session may reference a destroyed execution context. -
Missing frame lifecycle handling: OAuth redirects often involve cross-origin navigations. The relay forwards
Target.targetInfoChangedbut doesn't handlePage.frameNavigated/Page.frameStartedLoadingevents that Playwright needs to properly track frame state across navigations.
Expected Behavior
Snapshot should work after OAuth redirect chains complete. If the page is still loading during the redirect chain, snapshot should wait for load or return a clear "page is navigating" error.
Environment
- OpenClaw with Chrome extension relay
- CDP over WebSocket (loopback)
- Clerk auth with OAuth redirect chain