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:
- Page begins navigation
- A Cloudflare/WAF challenge interrupts the navigation mid-flight
- Firefox fires
Page.uncaughtError without a location field
- 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:117 — pageError.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.
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.uncaughtErrorprotocol event arrives withlocationomitted. The Node.js driver readspageError.location.urlunconditionally in two places, crashing the driver process with:Steps to Reproduce
Observed with Firefox (via camoufox, a patched Firefox variant) when:
Page.uncaughtErrorwithout alocationfieldOccurred 18 times over 11 days in a production crawl.
Root Cause
protocol.d.tstypesuncaughtErrorPayload.locationas 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:117—pageError.location.urlpackages/playwright-core/src/server/trace/recorder/tracing.ts:646— sameExpected Behavior
The
pageError/weberrorevents should fire normally whenlocationis absent, with empty fallback values (url: '',line: 0,column: 0) — consistent with how Chromium'sstackTraceToLocationalready handles the locationless case.