Skip to content

Commit 217d9c5

Browse files
committed
fix(hydration): record speculative snapshot for de-opt inserts and reorders
reconcileDeoptChildren recorded a speculative snapshot (hydration.save) only when removing an owned child. The empty-host append path and the survivor reorder path only called journalRootChildren, which feeds the root transaction journal but not the speculative arm's undo list. A resolved @Try arm that hit those paths and then suspended would leave client-built or reordered children in the server markup, so the retry could treat them as already matching. Add hydration.save(el) before both mutation paths, using the same isFresh guard as the removal path. save() is idempotent per parent via its saved Set, so it composes correctly when the removal path has already captured the element.
1 parent fd98909 commit 217d9c5

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎packages/octane/src/runtime.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33090,6 +33090,10 @@ function reconcileDeoptChildren(el: Element, children: any, ownerBlock: Block):
3309033090
// so just build + append each child. Skips the keyed-match Map / Set / reorder
3309133091
// bookkeeping below, which is the hot path for large initial mounts.
3309233092
if (firstChild === null) {
33093+
{
33094+
const hydration = activeHydration();
33095+
if (hydration !== null && !hydration.isFresh(el)) hydration.save(el);
33096+
}
3309333097
for (let i = 0; i < next.length; i++) {
3309433098
const node = reconcileDeoptNode(null, next[i], ownerBlock, childNs);
3309533099
if (node !== null) {
@@ -33194,6 +33198,10 @@ function reconcileDeoptChildren(el: Element, children: any, ownerBlock: Block):
3319433198
// Advance through owned live children once. Indexed childNodes reads restart
3319533199
// native list walks after each insertion; foreign ranges also must not make
3319633200
// every survivor rescan the preceding siblings.
33201+
{
33202+
const hydration = activeHydration();
33203+
if (hydration !== null && !hydration.isFresh(el)) hydration.save(el);
33204+
}
3319733205
let cursor: Node | null = getFirstChild(el);
3319833206
for (let i = 0; i < result.length; i++) {
3319933207
const want = result[i];

0 commit comments

Comments
 (0)