Skip to content

Commit af64ec1

Browse files
ryansolidClaude via Cursorcursoragent
committed
web/frames: trim the hold's bytes — one mounted read per occurrence in #syncSlots, the guard reads isHydrationInProgress alone
−48 B min on the frames client (43,411 → 43,363); the zombie check now precedes the {$ref} wait, so a zombie held on a ref is unmounted at once rather than when the ref resolves. Co-authored-by: Claude via Cursor <[email protected]> Co-authored-by: Cursor <[email protected]>
1 parent b39248f commit af64ec1

2 files changed

Lines changed: 11 additions & 11 deletions

File tree

‎packages/web/frames/src/client.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1431,7 +1431,7 @@ function adoptBoundary(
14311431
// its trigger once, which is not a read of this component's.
14321432
hold: () => {
14331433
const sc: any = sharedConfig;
1434-
return sc.holdBoundary && sc.isHydrationInProgress()
1434+
return sc.isHydrationInProgress?.()
14351435
? runWithOwner(owner, () => untrack(() => sc.holdBoundary("sc:" + id)))
14361436
: () => {};
14371437
},

‎packages/web/frames/src/frame-client.ts‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,25 +1358,25 @@ class FrameImpl {
13581358
// real args (an async one then suspends and holds, as the value tier
13591359
// intends). A fresh mount is skipped for the same reason — mounting
13601360
// with a fabricated `undefined` is what makes it visible.
1361-
if (record && record.kind === "slot" && this.#refsUnresolved(record.args)) {
1362-
waiting ||= !this.#mountedSlots.has(occurrence);
1363-
continue;
1364-
}
13651361
// A mount whose output the morph destroyed (its range was recreated
13661362
// inside a different server parent — ranges only relocate among
13671363
// siblings) is a zombie: remount fresh so content stays correct, even
13681364
// though state can't survive a destroyed node.
13691365
const prev = this.#slotNodes.get(occurrence);
13701366
const prevFirst = Array.isArray(prev) ? prev[0] : prev;
1367+
let mounted = this.#mountedSlots.has(occurrence);
13711368
// A data occurrence is never a zombie: its nodes are the server's
13721369
// consumers, not the fill's output — a replaced element is a consumer
13731370
// change (rebind, below), and an occurrence no element reads any more
13741371
// is simply not found (unmounted at the end).
1375-
const zombie =
1376-
!consumers && this.#mountedSlots.has(occurrence) && prevFirst && !prevFirst.parentNode;
1377-
if (zombie) {
1372+
if (!consumers && mounted && prevFirst && !prevFirst.parentNode) {
13781373
this.#mountedSlots.delete(occurrence);
13791374
this.#runSlotCleanups(occurrence);
1375+
mounted = false;
1376+
}
1377+
if (record && record.kind === "slot" && this.#refsUnresolved(record.args)) {
1378+
waiting ||= !mounted;
1379+
continue;
13801380
}
13811381
// The occurrence's name decides its class: the producer mints every
13821382
// CALLED occurrence as `prop#n` and emits its record at the call,
@@ -1406,19 +1406,19 @@ class FrameImpl {
14061406
// (a record dropped, or marker and record minted under different
14071407
// ids), never something the fill can fix; dev names it.
14081408
if (record === undefined && isCalled(occurrence)) {
1409-
waiting ||= !this.#mountedSlots.has(occurrence);
1409+
waiting ||= !mounted;
14101410
if (this.#options.adopt && this.#options.recordsPending?.()) {
14111411
this.#recordRefresh ??= setTimeout(() => {
14121412
this.#recordRefresh = null;
14131413
if (this.#disposed) return;
14141414
this.#options.drainRecords?.();
14151415
this.#syncSlots();
14161416
});
1417-
} else if ("_SOLID_DEV_" && consumers && !this.#mountedSlots.has(occurrence))
1417+
} else if ("_SOLID_DEV_" && consumers && !mounted)
14181418
devSlotOrphan(this, occurrence, consumers, "record");
14191419
continue;
14201420
}
1421-
if (!this.#mountedSlots.has(occurrence)) {
1421+
if (!mounted) {
14221422
// Direct-insert occurrences have no `slot:<id>` record and mount with
14231423
// empty props; render-function occurrences mount with resolved props.
14241424
// Mounting replaces the range interior: on a fresh stream it is

0 commit comments

Comments
 (0)