Skip to content

Browser extension relay: CDP session stale after OAuth/SPA redirect chains #16726

@jg-noncelogic

Description

@jg-noncelogic

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

  1. Start extension relay, attach a tab
  2. Navigate to a page that triggers OAuth (e.g., a Clerk <SignIn> component)
  3. The page redirects: app → clerk.example.com → provider → callback → app
  4. Attempt browser.snapshot() — fails with stale DOM or timeout
  5. Fresh snapshot with updated targetId also fails — relay tracks the tab correctly via Target.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:

  1. 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.

  2. No reconnection mechanism: When findPageByTargetId is 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.

  3. Missing frame lifecycle handling: OAuth redirects often involve cross-origin navigations. The relay forwards Target.targetInfoChanged but doesn't handle Page.frameNavigated / Page.frameStartedLoading events 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    staleMarked as stale due to inactivity

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions