Fix #15 - Transfer size 0 in Safari #18
Merged
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.
When doing cross-origin requests in Safari, the ResourceTiming
transferSize
field is force set to0
. There is more background into this behaviour in this issue: w3c/resource-timing#222The consequence is that download bandwidth calculations were using the value of this field as the numerator of the
size/time
equation, if it was present, leading to a miscalculation of0 bps
in these circumstances. This PR fixes that by interpreting a transfer size of0
as a missing field, and falling back to an estimation of the transfer size based on the bytes that were requested. This addresses #15.To note that this security behaviour only happens if the request is cross-origin, which explains why the issue isn't visible on the site https://speed.cloudflare.com since both the client and the server are on the same domain.
It also only affects Safari based browsers.
In addition, dev dependencies are bumped in this PR.