fix(firefox): guard undefined pageError.location in dispatcher#41629
Open
dimirey wants to merge 1 commit into
Open
fix(firefox): guard undefined pageError.location in dispatcher#41629dimirey wants to merge 1 commit into
dimirey wants to merge 1 commit into
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What / why
A page emitting an uncaught JS error whose
locationisundefinedcrashes the entire Node driver process with an unhandledTypeError: 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'sPageErrorlistener dereferencedpageError.location.urlunconditionally. Firefox can deliver an uncaught error with nolocation(reproducible with Firefox builds that omit it, e.g. Camoufox), so guard the access:A driver-process crash on absent protocol data is never desirable regardless of the Firefox build.
Notes
locationis present.