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.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Fix issues with stack traces and command log in Chrome 99 #20049
fix: Fix issues with stack traces and command log in Chrome 99 #20049
Changes from 5 commits
2921c16
74e964e
ed0ed36
6b489e1
3424f90
ac6af16
d2cabd8
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we start recursively inspecting objects, listing out their properties, this can include elements with references to objects like
window
anddocument
. And in Chrome 99, when we iterate over the properties ofdocument.adoptedStyleSheets
, it throws an error.Ultimately though, there's no reason we should be looking over every property of a
Document
. In the same way we already abort for HTMLElements above, I added an early exit for ShadowRoot and Document, returning a string of their HTML rather than recursively enumerating their properties. This should be a minor performance win, saving on hundreds of calls throughformatValue
in cases where we pass inwindow
,document
or other global-ish objects that aren't literal HTMLElements.No tests have been added, because the output of this function is already comprehensively tested - dozens of tests failed in Chrome 99 before the changes to this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🥳 yay to improved performance!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not understanding this comment 100%, which one is the trimmed one?
Above on line 142, we are setting
userInvocationStack = newErr.stack
so regardless of this check, won't the stack be the newError stack?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
captureStackTrace
modifies the error object in place. So for example, beforehand,newErr.stack
might will be 15 lines. Then we callcaptureStackTrace(newErr, captureUserInvocationStack)
, and nownewErr.stack
is only 10 lines long.This guard is against the case - in Chrome 99 - where it was already only two lines, and gets reduced to one. Eg, it might be
and it gets trimmed down to
I'm not 100% sure what caused the changed behavior of captureStackTrace in chromium 99, but the first stack trace is far more useful than the second.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ahhh the fact
captureStackTrace
modifies this as well was the part I was missing! Thanks for the extra info.