Skip to content

Commit cdfdb54

Browse files
committed
fix(octane): prune all created slots in pruneSignalRetryVisit regardless of position
Remove the last-slot exemption in pruneSignalRetryVisit that skipped replacement pruning for the final _slots entry when the scope suspended. The exemption assumed the last slot's identity was unproven, but every slot creation path (componentSlot, childSlot, ifBlock, switchBlock) assigns its identity fields (currentComp, branch, prevKey) before calling renderBlock for the slot's body. The occupant identity is therefore proven even when the body suspends mid-render. Without this fix, a slot whose occupant was replaced would retain the prior query$ owner whenever the scope suspended after the last slot finished rendering (e.g. a use() call after all JSX), because the completed slot was the last _slots entry and was skipped.
1 parent 9f25766 commit cdfdb54

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎packages/octane/src/runtime.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -865,9 +865,10 @@ let SIGNAL_RETRY_VISIT: SignalRetryVisit | null = null;
865865
// been. Its own path ends in the occupant identity of its parent's slot when
866866
// that segment is ['slot', index, kind, branch, component, key]; item and
867867
// scope segments cannot place a sole kind there. Every slot it created holds
868-
// this attempt's occupant, except one still rendering when it suspended. A
869-
// completed render that created no slot at an index renders nothing there; a
870-
// suspended one may not have reached it yet.
868+
// this attempt's occupant — identity fields (branch, currentComp, prevKey) are
869+
// assigned before the slot's body renders, so the occupant is proven even when
870+
// the body suspends mid-render. A completed render that created no slot at an
871+
// index renders nothing there; a suspended one may not have reached it yet.
871872
function pruneSignalRetryVisit(visit: SignalRetryVisit, suspended: boolean): void {
872873
const { scope, cache, path } = visit;
873874
const retired: SignalRendererOwnerIdentity[] = [];
@@ -880,16 +881,14 @@ function pruneSignalRetryVisit(visit: SignalRetryVisit, suspended: boolean): voi
880881
retired,
881882
);
882883
const slots = signalRetryNode(cache, path, false)?.children?.get('slot')?.children;
883-
const created = scope._slots;
884-
const rendering = suspended ? created?.[created.length - 1] : undefined;
885884
if (slots !== undefined) {
886885
for (const [index, node] of slots) {
887886
const slot = scope.slots[index as number];
888887
if (slot === null || typeof slot !== 'object') {
889888
if (suspended) continue;
890889
slots.delete(index);
891890
collectRetiredSignalRetryOwners(node, cache, retired);
892-
} else if (slot !== rendering && signalRetrySoleKind(slot.__kind)) {
891+
} else if (signalRetrySoleKind(slot.__kind)) {
893892
collectReplacedSignalRetryOccupants(
894893
node,
895894
slot.forSlot != null

0 commit comments

Comments
 (0)