Skip to content

fix(firefox): guard undefined pageError.location in dispatcher#41629

Open
dimirey wants to merge 1 commit into
microsoft:mainfrom
dimirey:fix-firefox-pageerror-undefined-location
Open

fix(firefox): guard undefined pageError.location in dispatcher#41629
dimirey wants to merge 1 commit into
microsoft:mainfrom
dimirey:fix-firefox-pageerror-undefined-location

Conversation

@dimirey

@dimirey dimirey commented Jul 5, 2026

Copy link
Copy Markdown

What / why

A page emitting an uncaught JS error whose location is undefined crashes the entire Node driver process with an unhandled TypeError: Cannot read properties of undefined (reading 'url'), rather than surfacing the error to the client. Because the crash happens upstream of event dispatch, page.on('pageerror') cannot intercept it. Regression from #39767 (shipped 1.60.0).

Fixes #41628.

The fix

BrowserContextDispatcher's PageError listener dereferenced pageError.location.url unconditionally. Firefox can deliver an uncaught error with no location (reproducible with Firefox builds that omit it, e.g. Camoufox), so guard the access:

location: {
  url: pageError.location?.url ?? '',
  line: pageError.location?.lineNumber ?? 0,
  column: pageError.location?.columnNumber ?? 0,
},

A driver-process crash on absent protocol data is never desirable regardless of the Firefox build.

Notes

  • Minimal, defensive one-liner; no behavior change when location is present.
  • Happy to add a regression test if you can point me at the right fixture/harness — the trigger is a locationless uncaught page error, which needs a crafted Firefox fixture to reproduce deterministically.

A page emitting an uncaught error with an undefined `location` crashed the
Node driver process with an unhandled `TypeError: Cannot read properties of
undefined (reading 'url')` (regression from microsoft#39767), instead of surfacing the
error to the client. The crash is upstream of dispatch, so `page.on('pageerror')`
cannot catch it. Guard the location access with optional chaining + defaults.

Fixes microsoft#41628

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Firefox — driver crashes with unhandled TypeError when a page error has no location

1 participant