From 4d0942d71e29443fa98b56952581f825bb9f1767 Mon Sep 17 00:00:00 2001 From: Sebastian Markbage Date: Wed, 21 May 2025 20:10:17 -0400 Subject: [PATCH] Pass batch as argument to revealCompletedBoundaries This solves a race condition when boundaries are added to the batch after the startViewTransition call. --- ...tDOMFizzInstructionSetInlineCodeStrings.js | 4 ++-- .../ReactDOMFizzInstructionSetShared.js | 24 ++++++++++++------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetInlineCodeStrings.js b/packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetInlineCodeStrings.js index aa7209fadac1d..429876692eb8d 100644 --- a/packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetInlineCodeStrings.js +++ b/packages/react-dom-bindings/src/server/fizz-instruction-set/ReactDOMFizzInstructionSetInlineCodeStrings.js @@ -6,9 +6,9 @@ export const markShellTime = export const clientRenderBoundary = '$RX=function(b,c,d,e,f){var a=document.getElementById(b);a&&(b=a.previousSibling,b.data="$!",a=a.dataset,c&&(a.dgst=c),d&&(a.msg=d),e&&(a.stck=e),f&&(a.cstck=f),b._reactRetry&&b._reactRetry())};'; export const completeBoundary = - '$RB=[];$RV=function(){$RT=performance.now();var d=$RB;$RB=[];for(var a=0;a { + // TODO + }); transition.finished.finally(() => { if (document['__reactViewTransition'] === transition) { document['__reactViewTransition'] = null; } }); + // Queue any future completions into its own batch since they won't have been + // snapshotted by this one. + window['$RB'] = []; return; } // Fall through to reveal. @@ -109,7 +117,7 @@ export function revealCompletedBoundariesWithViewTransitions(revealBoundaries) { // Fall through to reveal. } // ViewTransitions v2 not supported or no ViewTransitions found. Reveal immediately. - revealBoundaries(); + revealBoundaries(batch); } export function clientRenderBoundary( @@ -182,7 +190,7 @@ export function completeBoundary(suspenseBoundaryID, contentID) { // We always schedule the flush in a timer even if it's very low or negative to allow // for multiple completeBoundary calls that are already queued to have a chance to // make the batch. - setTimeout(window['$RV'], msUntilTimeout); + setTimeout(window['$RV'].bind(null, window['$RB']), msUntilTimeout); } }