-
Notifications
You must be signed in to change notification settings - Fork 795
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(plugin-fetch): check if PerformanceObserver exists #1662
Conversation
exists before using it.
Codecov Report
@@ Coverage Diff @@
## master #1662 +/- ##
==========================================
- Coverage 92.58% 92.38% -0.21%
==========================================
Files 174 157 -17
Lines 6045 5108 -937
Branches 1286 1091 -195
==========================================
- Hits 5597 4719 -878
+ Misses 448 389 -59 |
Would like @obecny input on this |
@@ -225,7 +228,9 @@ export class FetchPlugin extends core.BasePlugin<Promise<Response>> { | |||
response: FetchResponse | |||
) { | |||
const endTime = core.hrTime(); | |||
spanData.observer.disconnect(); | |||
if (spanData.observer) { |
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.
you can shorten the whole if
to one liner as it was previously just add ?
if (spanData.observer) { | |
spanData.observer?.disconnect(); |
|
||
describe('when PerformanceObserver is undefined', () => { | ||
beforeEach(done => { | ||
Object.defineProperty(window, 'PerformanceObserver', { |
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.
please use sandbox.stub
for that
@@ -174,6 +174,9 @@ export class FetchPlugin extends core.BasePlugin<Promise<Response>> { | |||
): void { | |||
let resources: PerformanceResourceTiming[] = resourcesObserver.entries; | |||
if (!resources.length) { | |||
if (!performance.getEntriesByType) { |
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.
Please add unit test for that - use sandbox
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.
Done, wanted to do a cleaner solution but ran into a bunch of issues
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.
lgtm
waiting for one more reviewer. i'm fine to merge without if @obecny is |
Which problem is this PR solving?
Short description of the changes