-
Notifications
You must be signed in to change notification settings - Fork 140
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
🐛 [RUM-4434] fix timing matching for the same resource requested twice at the same time #2747
Conversation
Bundles Sizes Evolution
🚀 CPU Performance
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2747 +/- ##
==========================================
+ Coverage 93.27% 93.28% +0.01%
==========================================
Files 241 241
Lines 7034 7049 +15
Branches 1554 1555 +1
==========================================
+ Hits 6561 6576 +15
Misses 473 473 ☔ View full report in Codecov by Sentry. |
packages/rum-core/src/domain/resource/matchRequestTiming.spec.ts
Outdated
Show resolved
Hide resolved
request.startClocks.relative, | ||
endTime({ startTime: request.startClocks.relative, duration: request.duration }) | ||
) | ||
) | ||
|
||
if (candidates.length === 1) { | ||
return candidates[0] | ||
matchedResourceTimingEntries.set(candidates[0].original, PLACEHOLDER) |
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.
❓ question: any evidence that when two entries are matching the same timing, one entry has already matched another timing?
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.
In the case of fetch, having two timing matching the same resource without being already matched, means that both timings are available before the then
of the first fetch is called.
This is not the case when doing Promise.all()
but I don't exclude the possibility of it happening. In that case no timing will be matched.
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.
Would it be worth doing more experiments on browser behaviours around that? or measure the effectiveness of this change somehow?
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 adding a e2e test, however I've noticed that safari doesn't do like everyone and both PerformanceResourceTiming
might be available at the time the first resource is matching it's timings.
This means that this PR reduce the amount of occurrence of missing resource timing on concurrent event (mainly chrome/FF) but does not prevent it totally (safari)
anyone has a better idea?
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.
as discussed during parking lot, this PR won't solve everything but is improving in some cases. So I've skipped the e2e on non chromium browsers as it's not reliable there.
packages/rum-core/src/domain/resource/matchRequestTiming.spec.ts
Outdated
Show resolved
Hide resolved
/to-staging |
🚂 Branch Integration: starting soon, merge in < 9m Commit 84d8e5e469 will soon be integrated into staging-20. This build is going to start soon! (estimated merge in less than 9m) Use |
Commit 84d8e5e469 had already been merged into staging-20 If you need support, contact us on Slack #devflow! |
Motivation
Fixes an issue where resource timing where not matched to a resource when the same resource is requested twice at the same time.
e.g.
The issue is that when the second request resolves, we have 2 resource timings matching the request hence we were not able to decide which one is the correct one.
Changes
When a match is found between a resource timing and a request, we store the timing in a
WeakMap
, that way we can filter it out of the available timings when the 2nd resource resolve.Testing
I have gone over the contributing documentation.