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

Ignore TTFB for loads where responseStart is zero #281

Merged
merged 2 commits into from Nov 14, 2022

Conversation

philipwalton
Copy link
Member

This PR fixes #275 by ignoring loads where the responseStart property of the navigation entry is 0. The assumption is that responseStart should never be zero unless the browser is intentionally concealing navigation timing data.

src/onTTFB.ts Outdated

// In some cases the value reported is negative or is larger
// than the current page time. Ignore these cases:
// https://github.com/GoogleChrome/web-vitals/issues/137
// https://github.com/GoogleChrome/web-vitals/issues/162
if (metric.value < 0 || metric.value > performance.now()) return;
if (responseStart < 0 || responseStart > performance.now()) return;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, I revert this to using responseStart instead of metric.value because metric.value is being clamped at 0 above, which makes this check mostly useless now. Using responseStart reverts the logic to what it was originally trying to check.

src/onTTFB.ts Outdated Show resolved Hide resolved
@philipwalton
Copy link
Member Author

Ok, updated and rebased to pick up the latest changes on main.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

TTFB (under)reporting 0ms on Safari + utm/gclid params
2 participants