Skip to content

Commit 820abeb

Browse files
committed
fix(hydration): sweep rebuilt tail on retry and fix markerless in-place cursor
Bug 1: A deferred same-block retry re-enters renderBranchSlot with state.block already set. That path only called renderBlock without sweepRebuiltTail, so unclaimed server nodes after a rebuilt root survived when the first attempt suspended before sweeping. Add the sweep after renderBlock in the retry path. Bug 2: The markerless branch path called renderBlock directly when a server node at the cursor could be adopted in place. clone() leaves the cursor on the adopted root, and holes inside it move the cursor into its children. markerlessEnd then saw the cursor outside the branch parent and returned after, overclaiming following siblings. Wrap the render in renderInPlace when there is a cursor, which steps the cursor past the adopted root after a successful adoption.
1 parent 204479b commit 820abeb

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

‎packages/octane/src/runtime.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42306,7 +42306,8 @@ function renderBranchSlot(
4230642306
state.block = b;
4230742307
state.markerlessBefore = before;
4230842308
try {
42309-
renderBlock(b);
42309+
if (cursor !== null) hydration!.renderInPlace(renderBlock, b, cursor);
42310+
else renderBlock(b);
4231042311
} catch (error) {
4231142312
// A branch that throws before inserting anything stays unfinalized so
4231242313
// a same-branch retry finalizes it. One that already inserted its
@@ -42392,6 +42393,8 @@ function renderBranchSlot(
4239242393
state.block.body = body!;
4239342394
state.block.extra = env;
4239442395
renderBlock(state.block);
42396+
if (hydration !== null && hydration.rebuiltTail !== null)
42397+
hydration.sweepRebuiltTail(state.block.endMarker);
4239542398
const markerlessBefore = state.markerlessBefore;
4239642399
if (markerlessBefore !== undefined) {
4239742400
finalizeMarkerlessBranch(

0 commit comments

Comments
 (0)