Skip to content

Commit

Permalink
Add a guard to prevent errors in onCLS
Browse files Browse the repository at this point in the history
  • Loading branch information
philipwalton committed Sep 27, 2024
1 parent 87d8406 commit e1c2d75
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/onCLS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,9 @@ export const onCLS = (
// session.
if (
sessionValue &&
// `lastSessionEntry` will be defined if `sessionsValue` is.
entry.startTime - lastSessionEntry!.startTime < 1000 &&
firstSessionEntry &&
lastSessionEntry &&
entry.startTime - lastSessionEntry.startTime < 1000 &&
entry.startTime - firstSessionEntry.startTime < 5000
) {
sessionValue += entry.value;
Expand Down

0 comments on commit e1c2d75

Please sign in to comment.