From c2681ebfb89d18f19567ad6d8277e2b69bcec85e Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Wed, 2 Apr 2025 00:16:21 -0400 Subject: [PATCH] Follow through all the phases when an error happens during snapshotting --- .../src/client/ReactFiberConfigDOM.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js index b9e63fed94b5c..83092a87318ca 100644 --- a/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js +++ b/packages/react-dom-bindings/src/client/ReactFiberConfigDOM.js @@ -1802,6 +1802,12 @@ export function startViewTransition( } } finally { // Continue the reset of the work. + // If the error happened in the snapshot phase before the update callback + // was invoked, then we need to first finish the mutation and layout phases. + // If they're already invoked it's still safe to call them due the status check. + mutationCallback(); + layoutCallback(); + // Skip afterMutationCallback() since we're not animating. spawnedWorkCallback(); } }; @@ -2137,7 +2143,13 @@ export function startGestureTransition( } } finally { // Continue the reset of the work. - readyCallback(); + // If the error happened in the snapshot phase before the update callback + // was invoked, then we need to first finish the mutation and layout phases. + // If they're already invoked it's still safe to call them due the status check. + mutationCallback(); + // Skip readyCallback() and go straight to animateCallbck() since we're not animating. + // animateCallback() is still required to restore states. + animateCallback(); } }; transition.ready.then(readyForAnimations, handleError);