-
Notifications
You must be signed in to change notification settings - Fork 29
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: safe performance.getEntriesByType
#5849
Conversation
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.
great catch!
performance.getEntriesByType
Some browsers do not support this method, so we check for its existence before measuring the time taken. Fixes CLIENT-SIDE-PROD-CSXR Fixes CLIENT-SIDE-PROD-CTRH
4370130
to
a64ff08
Compare
I guess there are a few non-equivalent ways of checking whether an object has a property/method in js, right? I'm never clear on exactly which to use when. |
Size Change: +25 B (0%) Total Size: 1.65 MB ℹ️ View Unchanged
|
⚡️ Lighthouse report for the changes in this PRLighthouse tested 2 URLs Report for Article
Report for Front
|
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.
Looks good!
Thanks for the question. The fact that you raised this means we might have to capture this information more clearly. I will merge this PR now we can use issue #5853 to discuss this further. The reason I am using the window.performance.getEntriesByType?.('measure');
// Via https://typescript-eslint.io/rules/no-unnecessary-condition/ ESLint auto-fixes to:
window.performance.getEntriesByType('measure'); An alternative would be to disable that rule locally, which might be more explicit? What do you think, @bryophyta: // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition -- not all browsers
window.performance.getEntriesByType?.('measure'); |
What does this change?
Some browsers do not support
window.performance.getEntriesByType
, so we check for its existence before measuring the time taken.Why?
This is the top reported
TypeError
in Sentry.Fixes CLIENT-SIDE-PROD-CSXR
Fixes CLIENT-SIDE-PROD-CTRH
This method was Introduced in #5298.
Related to the fix in #5299