@samitouri / QOS-React / commits / 3366146796

Fix `Failed to execute 'measure' on 'Performance'` error (#32823)

When `startTime` still has its initial value of `-1.1` we must not call `logComponentMount`. This can occur when rendering a `'next/dynamic'` component with `{ssr: false}` in a client component, for example. Unfortunately, I didn't manage to reproduce this scenario in a unit test.

Hendrik Liebau committed Apr 7, 2025 at 16:13 UTC 336614679600af371b06371c0fbdd31fd9838231
1 file changed +2 -2
packages/react-reconciler/src/ReactFiberCommitWork.js
+2 -2
@@ -3756,7 +3756,7 @@ function commitPassiveMountOnFiber(
3756 ) {
3757 // Log the reappear in the render phase.
3758 const startTime = ((finishedWork.actualStartTime: any): number);
3759 - if (endTime - startTime > 0.05) {
3759 + if (startTime >= 0 && endTime - startTime > 0.05) {
3760 logComponentReappeared(finishedWork, startTime, endTime);
3761 }
3762 if (
@@ -3861,7 +3861,7 @@ function commitPassiveMountOnFiber(
3861 if (isMount) {
3862 // Log the mount in the render phase.
3863 const startTime = ((finishedWork.actualStartTime: any): number);
3864 - if (endTime - startTime > 0.05) {
3864 + if (startTime >= 0 && endTime - startTime > 0.05) {
3865 logComponentMount(finishedWork, startTime, endTime);
3866 }
3867 }