Skip to content

Commit

Permalink
Ensure reported values are less than page time
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwalton committed Oct 11, 2021
1 parent 225ed14 commit f7d38b4
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 f7d38b4

Please sign in to comment.