reportAllChanges throws TypeError: Cannot read properties of undefined (reading 'startTime')
Description
Chrome DevTools throws an uncaught TypeError from its embedded copy of web-vitals during client-side (soft) navigations.
The stack is entirely in an anonymous VM* script injected by Chrome DevTools (et.reportAllChanges → n.timeout). There are no application frames. The bytecode offsets match this report:
That issue was filed against Angular, but the same crash also happens in other SPAs that do not use Angular and do not import web-vitals. It only appears in Chrome with DevTools open.
This looks like a missing null check in reportAllChanges when a performance entry has already been cleared or reset after a soft navigation, then processed later via setTimeout / idle callback.
Related:
- https://github.com/GoogleChrome/web-vitals/issues/274
- https://github.com/GoogleChrome/web-vitals/issues/669
- https://github.com/GoogleChrome/web-vitals/pull/758
If the crashing code is the DevTools-bundled build rather than an app-installed package, a fix here would still need to land in Chromium DevTools.
Expected
reportAllChanges should skip missing entries and never throw.
Actual
Uncaught TypeError: Cannot read properties of undefined (reading 'startTime') at et.reportAllChanges (:2:19429) at :2:13070 at :2:331 at d (:2:6141) at u (:2:6153) at :2:6321 at :2:2895 at n.timeout (:2:5652)
Offsets :2:19429 (reportAllChanges) and :2:5652 (n.timeout) are identical to https://github.com/angular/angular/issues/70464.
Source: GoogleChrome/web-vitals