Skip to content
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 #15 - Transfer size 0 in Safari #18

Merged
merged 3 commits into from
Jun 20, 2023
Merged

Conversation

vasturiano
Copy link
Contributor

When doing cross-origin requests in Safari, the ResourceTiming transferSize field is force set to 0. There is more background into this behaviour in this issue: w3c/resource-timing#222

The 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 of 0 bps in these circumstances. This PR fixes that by interpreting a transfer size of 0 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.

@github-actions
Copy link
Contributor

Please set a semver versioning label of either major, minor, or patch on this pull request.

@vasturiano vasturiano merged commit ffd16a5 into main Jun 20, 2023
@vasturiano vasturiano deleted the 15-safari-transferSize branch June 21, 2023 00:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants