You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Bug: Throttled Suspense retry commit can be scheduled twice and throw "Cannot commit the same tree as before" #38396
Versions: react / react-reconciler 19.2.4 (the copy @react-three/fiber 9.5.0 bundles); the same code is on main as of 2026-11-25.
What happens. Rarely, under a slow CPU, an uncaught Error: Cannot commit the same tree as before is thrown from a timer.
The stack is only commitRoot ← commitRootWhenReady (a setTimeout callback). Nothing visible breaks: the same tree was
already committed by an earlier timer.
Why (from reading ReactFiberWorkLoop.js):
A retry render (retry lanes only) completes within FALLBACK_THROTTLE_MS of a fallback being shown. finishConcurrentRender
schedules root.timeoutHandle = scheduleTimeout(commitRootWhenReady.bind(...), msUntilTimeout). The finished render
stays as workInProgressRoot / workInProgressRootRenderLanes.
A ping for exactly those lanes arrives: a wakeable whose ping listener was attached in an earlier render on the same retry
lane (there are only four), resolving now. pingSuspendedRoot restarts only for RootSuspendedWithDelay, or for RootSuspended
inside the throttle window. For RootCompleted it merges workInProgressRootPingedLanes and calls ensureRootIsScheduled.
performWorkOnRoot runs for the same lanes. renderRootSync/Concurrent call prepareFreshStack only when workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes, so the pending timeoutHandle is not cancelled.
The completed render is returned again, throttled again, and root.timeoutHandle is overwritten by a second timer.
Both timers call commitRootWhenReady with the same finishedWork. The second finds finishedWork === root.current and
throws. (In another variant the re-run commits synchronously: commitRootWhenReady clears root.timeoutHandle = noTimeout
without cancelling the first timer, which fires later on the committed tree.)
Suggested fix: in finishConcurrentRender, cancel an existing root.timeoutHandle before scheduling a new one. In
commitRootWhenReady, cancel a pending handle other than the running one before committing. Alternatively, treat
RootCompleted like RootSuspended in pingSuspendedRoot within the throttle window.
Repro context: a React Three Fiber scene where many components suspend on separately loading assets (about 20 GLB models,
each in its own <Suspense fallback={null}>), loaded on a slow device. Seen about 1 in 13 runs under heavy CPU load; not
reproduced on demand with 6x CPU throttling (0 in 30).
Activity