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

Ensure reported TTFB values are less than the current page time #187

Merged
merged 1 commit into from Oct 11, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/getTTFB.ts
Expand Up @@ -59,9 +59,11 @@ export const getTTFB = (onReport: ReportHandler) => {
metric.value = metric.delta =
(navigationEntry as PerformanceNavigationTiming).responseStart;

// In some cases the value reported is negative. Ignore these cases:
// 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
if (metric.value < 0) return;
// https://github.com/GoogleChrome/web-vitals/issues/162
if (metric.value < 0 || metric.value > performance.now()) return;

metric.entries = [navigationEntry];

Expand Down