Skip to main content
Internal Service β€” This is not an HTTP endpoint. It’s called by the browser-session route.

Purpose

Connects to a Browserbase session via Playwright CDP and navigates to a URL. Runs as a background task so the API response isn’t blocked.

Function Signature

async def _navigate_in_background(connect_url: str, url: str, session_id: str)

Parameters

ParameterTypeDescription
connect_urlstrBrowserbase WebSocket URL
urlstrTarget URL to navigate to
session_idstrSession ID for logging

What It Does

  1. Connect - Playwright connects via CDP (Chrome DevTools Protocol)
  2. Navigate - Go to URL, wait for DOM content loaded
  3. Polish - Hide scrollbars for cleaner embed
  4. Scroll Animation - Automated scrolling to simulate β€œscanning”

Scroll Animation Sequence

[0s]   Page loaded
[2s]   First scroll: 1.5 viewport heights over 1.5s
[8.5s] Second scroll: 1 viewport height over 1.5s
[10s]  Complete

Background Task Pattern

# Start task without blocking
task = asyncio.create_task(
    _navigate_in_background(connect_url, body.url, session_id)
)
_NAVIGATION_TASKS[session_id] = task

# Return immediately
return BrowserSessionResponse(session_id=session_id, live_url=live_url)

Code Location

src/website/browser_session/routes.py
# Lines 51-112: _navigate_in_background()