GoogleChrome / web-vitals

Essential metrics for a healthy site.
https://web.dev/vitals
Apache License 2.0
7.62k stars 418 forks source link

Add a guard to prevent errors in the onCLS() function #536

Closed philipwalton closed 1 month ago

philipwalton commented 1 month ago

This PR fixes an error where the CLS session window logic tries to access startTime of an undefined entry.

It's still a mystery how this can possibly happen, but given that at least three people have reported it over the years. It's probably worth adding a guard for:

Addresses the following issues:

(Note: the base branch here is temporary to make the diff easier to see. I'll updated it after the other PRs are merged into the v5 branch.)