Skip to content

Commit 34762d6

Browse files
committed
fix(octane): restore retirement stamp in detachDeoptTreeRefs for non-transactional teardown
The perf commit dropped the root-level retireEventHostTree call from detachDeoptTreeRefs, assuming all blockless de-opt removals route through deferRootRange. Several paths still detach hosts immediately outside a root transaction: clearChildContent's non-deferred sweep, clone() adoption replaceChild/replaceChildren, unmountSlot's hostNode teardown, and multiple reconciler else-branches. A focused host on those paths dispatches focusout synchronously without retirement, letting its handler fire on a stale node. Restore the root-only retirement stamp so every teardown call (out === null) retires the subtree root before detach. The transactional path double-retires harmlessly (idempotent epoch bump).
1 parent 29ba34b commit 34762d6

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎packages/octane/src/runtime.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44438,7 +44438,11 @@ function detachDeoptTreeRefs(
4443844438
ownerScope?: Scope,
4443944439
uncommitted: UncommittedRefAttaches | null = null,
4444044440
activityRefs: WeakMap<Element | FragmentInstance, ActivityRefState> | null = null,
44441+
// Only the removed subtree's root carries the retirement stamp.
44442+
root: boolean = true,
4444144443
): void {
44444+
// Teardown runs just before every blockless de-opt removal detaches `node`.
44445+
if (root && out === null) retireEventHostTree(node);
4444244446
// No de-opt descriptor ref was ever stamped → nothing to detach or collect
4444344447
// anywhere; skip the subtree scan. (Monotone flag — see noteDeoptRef.)
4444444448
if (!DEOPT_REFS_STAMPED) return;
@@ -44472,7 +44476,7 @@ function detachDeoptTreeRefs(
4447244476
c = nodeAfterPortalRange(c, rangeEnd);
4447344477
continue;
4447444478
}
44475-
detachDeoptTreeRefs(c, out, shouldDetach, ownerScope, uncommitted, activityRefs);
44479+
detachDeoptTreeRefs(c, out, shouldDetach, ownerScope, uncommitted, activityRefs, false);
4447644480
c = getNextSibling(c);
4447744481
}
4447844482
}

0 commit comments

Comments
 (0)