-
Notifications
You must be signed in to change notification settings - Fork 821
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(fetch): end span after body is received #2203
Conversation
Codecov Report
@@ Coverage Diff @@
## main #2203 +/- ##
==========================================
- Coverage 92.72% 92.71% -0.02%
==========================================
Files 141 141
Lines 5089 5106 +17
Branches 1047 1049 +2
==========================================
+ Hits 4719 4734 +15
- Misses 370 372 +2
|
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.
this is really nice finding, thx for fixes, lgtm, just some name change suggestions
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.
+1
@dyladan @vmarchaud Can I get one more review and if possible get it merged soon? Would really like to have this before next release. |
Which problem is this PR solving?
Currently fetch span end is called when
fetch().then
fires and 300ms wait time(for resource timings) is over. But fetch() promise resolves as soon as the server responds with headers so if getting the body takes more than 300ms there will never be any resource timings for this span and span end time will be incorrect also. To reproduce it just make a fetch and set connection speed slow in dev tools and you can see that none of the fetches have resource timings.Short description of the changes
I clone the response and read the response body until it is done and end the span then. Not a pretty solution but this covers all of the cases I know about. Another potential way to fix this would be to wrap all body methods (.json .blob etc.) but that still leaves some use cases uncovered. Some changes to tests so done isn't called too early (took a looong time to get them stable). Also fixed some TS warnings in tests. Probably could get rid of the 300ms timeout now but I am not yet bold enough.