Skip to content

Commit

Permalink
Merge pull request #187 from GoogleChrome/invalid-ttfb
Browse files Browse the repository at this point in the history
Ensure reported values are less than page time
  • Loading branch information
philipwalton committed Oct 11, 2021
2 parents 225ed14 + f7d38b4 commit 0020d02
Showing 1 changed file with 4 additions and 2 deletions.
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

0 comments on commit 0020d02

Please sign in to comment.