Skip to content

fix(firefox): Firefox Page.uncaughtError may omit location, crashing driver process #41169

@ottowainright

Description

@ottowainright

Description

When Firefox fires an uncaught-error event while the page is mid-navigation (e.g. interrupted by a Cloudflare challenge or other redirect), the Page.uncaughtError protocol event arrives with location omitted. The Node.js driver reads pageError.location.url unconditionally in two places, crashing the driver process with:

TypeError: Cannot read properties of undefined (reading 'url')
  at FFBrowserContext.<anonymous> (packages/playwright-core/src/server/dispatchers/browserContextDispatcher.ts:117)
  at _Page.addPageError (packages/playwright-core/src/server/page.ts)
  at FFPage._onUncaughtError (packages/playwright-core/src/server/firefox/ffPage.ts:274)

Steps to Reproduce

Observed with Firefox (via camoufox, a patched Firefox variant) when:

  1. Page begins navigation
  2. A Cloudflare/WAF challenge interrupts the navigation mid-flight
  3. Firefox fires Page.uncaughtError without a location field
  4. Driver process crashes, killing the browser context

Occurred 18 times over 11 days in a production crawl.

Root Cause

protocol.d.ts types uncaughtErrorPayload.location as required, but in practice Firefox can omit the field when errors fire without a source location (mid-navigation race). The crash sites:

  • packages/playwright-core/src/server/dispatchers/browserContextDispatcher.ts:117pageError.location.url
  • packages/playwright-core/src/server/trace/recorder/tracing.ts:646 — same

Expected Behavior

The pageError / weberror events should fire normally when location is absent, with empty fallback values (url: '', line: 0, column: 0) — consistent with how Chromium's stackTraceToLocation already handles the locationless case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions