Skip to content

Commit b0ff3d0

Browse files
raeyoung-kimijjk
andcommitted
Fix startTime error on Android 9 with Chrome 74 (#67391)
### What? Fixes the error `Cannot read property 'startTime' of null` on Chrome 74 for Android 9 by ensuring the `beforeHydrationMeasure` and `hydrationMeasure` are not falsy values before accessing their properties. <img width="1164" alt="Screenshot 2024-07-02 at 11 14 53 PM" src="https://github.com/vercel/next.js/assets/52588326/34df95b6-a4fe-4886-96b8-a3c873a2ae6a"> ### Why? The application crashes on Chrome 74 for Android 9 due to `null` or other falsy values being returned in certain situations. This fix ensures that the `startTime` property is only accessed if it is not a falsy value, thereby preventing the crash. ### How? Added a falsy check before accessing the `startTime` property in the performance measurement logic. Specifically, modified the code at [this location](https://github.com/vercel/next.js/blob/b9bd23baec14508400c502b3651f4cf2497e883b/packages/next/src/client/index.tsx#L498) Co-authored-by: JJ Kasper <[email protected]>
1 parent 49566f5 commit b0ff3d0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

packages/next/src/client/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -496,8 +496,8 @@ function markHydrateComplete(): void {
496496
if (
497497
process.env.NODE_ENV === 'development' &&
498498
// Old versions of Safari don't return `PerformanceMeasure`s from `performance.measure()`
499-
beforeHydrationMeasure !== undefined &&
500-
hydrationMeasure !== undefined
499+
beforeHydrationMeasure &&
500+
hydrationMeasure
501501
) {
502502
tracer
503503
.startSpan('navigation-to-hydration', {

0 commit comments

Comments
 (0)