Skip to content

fix(firefox): guard against missing location in uncaughtError protocol event#41173

Open
ottowainright wants to merge 2 commits into
microsoft:mainfrom
ottowainright:fix-41169
Open

fix(firefox): guard against missing location in uncaughtError protocol event#41173
ottowainright wants to merge 2 commits into
microsoft:mainfrom
ottowainright:fix-41169

Conversation

@ottowainright
Copy link
Copy Markdown

Summary

  • Firefox can omit location in Page.uncaughtError protocol events when an uncaught error fires during mid-navigation (e.g. interrupted by a WAF challenge), crashing the driver with TypeError: Cannot read properties of undefined (reading 'url')
  • Make uncaughtErrorPayload.location optional in protocol.d.ts to match actual Firefox behaviour
  • Widen PageError.location and addPageError() to accept undefined
  • Use ?. + ?? fallbacks in the dispatcher and tracing recorder — consistent with how Chromium's stackTraceToLocation already handles the locationless case
  • Add a Firefox-only test that injects a synthetic Page.uncaughtError without location into the protocol session and verifies pageerror/weberror fire without crashing

Fixes #41169

johnhight added 2 commits June 5, 2026 10:48
…l event

Firefox can omit the location field in Page.uncaughtError events when an
uncaught error fires during mid-navigation (e.g. interrupted by a WAF
challenge). Reading pageError.location.url unconditionally crashes the
driver process.

- Make uncaughtErrorPayload.location optional in protocol.d.ts
- Widen PageError.location and addPageError() to accept undefined
- Use optional-chain + empty-string/zero fallbacks in the dispatcher
  and tracing recorder (consistent with Chromium's stackTraceToLocation)

Fixes: microsoft#41169
…ify no crash

Replace the weak end-to-end guard with a test that injects a synthetic
Page.uncaughtError event with no location field directly into the Firefox
protocol session. This exercises the exact code path that crashed before
the fix and will fail on the unfixed code.

Fixes: microsoft#41169
@ottowainright
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

frameId: string;
message: string;
stack: string;
location: {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this file is generated, it means that the bug is on the firefox end where it doesn't send the location and we should fix it there

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.

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

3 participants