Skip to content

Commit 227517d

Browse files
committed
Merge remote-tracking branch 'origin/next' into claude/project-thread-x1ore2-seat-release-guard
2 parents c3672f7 + b249ad9 commit 227517d

4 files changed

Lines changed: 105 additions & 61 deletions

File tree

‎packages/web/test/async-gen/emit.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ import type { Node, Read, Scenario, SrcRef } from "./scenario.js";
1414
export interface AppContext {
1515
values: number[];
1616
ask(name: string, v: number, poison: number | null): unknown;
17+
/** Called just before memo `name` is created (the client half reads the
18+
* hydration id it will take). */
19+
id?(name: string): void;
1720
}
1821

1922
const ref = (r: SrcRef) => (r.k === "s" ? `S[${r.i}][0]` : `M[${r.i}]`);
@@ -56,8 +59,8 @@ export function emitApp(sc: Scenario): string {
5659
.join(" + ");
5760
const poison = m.poison === null ? "null" : String(m.poison);
5861
return m.async
59-
? ` M[${i}] = createMemo(() => { const v = 1 + ${input}; return ctx.ask("m${i}", v, ${poison}); });`
60-
: ` M[${i}] = createMemo(() => { const v = 1 + ${input}; if (${poison} !== null && v % 4 === ${poison}) throw new Error("m${i}:" + v); return v; });`;
62+
? ` ctx.id?.("m${i}");\n M[${i}] = createMemo(() => { const v = 1 + ${input}; return ctx.ask("m${i}", v, ${poison}); });`
63+
: ` ctx.id?.("m${i}");\n M[${i}] = createMemo(() => { const v = 1 + ${input}; if (${poison} !== null && v % 4 === ${poison}) throw new Error("m${i}:" + v); return v; });`;
6164
})
6265
.join("\n");
6366
return `/**

‎packages/web/test/consistency/async-gen/hydrate.spec.tsx‎

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,12 @@
1010
*
1111
* Per case, the shell is hydrated and every chunk applied, then:
1212
*
13-
* - NO REFETCH: no memo asks again before the first client write (an ask
14-
* made under hydration's dry run, with its fake Promise, is not one).
13+
* - NO REFETCH (Ryan, 2026-10-30): "a refetch is a re-ask of a read the
14+
* server answered (value or error); a first ask of a read the server
15+
* never reached is the client's ordinary ask". Hydration is CSR with the
16+
* server's answers claimed, so an ask counts only when the payload carries
17+
* that memo's answer and it comes before the first client write. An ask
18+
* made under hydration's dry run, with its fake Promise, is not one.
1519
* - CLEAN: no console.error, no hydration warning.
1620
* - HYDRATED = CSR: the hydrated screen equals a fresh client render of the
1721
* same inputs with every memo synchronous.
@@ -24,11 +28,12 @@
2428
import { readFileSync, existsSync, writeFileSync } from "node:fs";
2529
import { resolve } from "node:path";
2630
import { expect, test } from "vitest";
27-
import { action, flush, resetErrorHalt } from "solid-js";
31+
import { action, flush, getOwner, resetErrorHalt } from "solid-js";
32+
import { peekNextChildId } from "@solidjs/signals";
2833
import { hydrate, render } from "@solidjs/web";
2934
import { sharedConfig } from "solid-js/internal";
3035
import type { AppContext } from "../../async-gen/emit.js";
31-
import type { Node, Scenario, SrcRef } from "../../async-gen/scenario.js";
36+
import type { Scenario } from "../../async-gen/scenario.js";
3237
import { describeScenario } from "../../async-gen/scenario.js";
3338
import { recordOrDiff, type Trace } from "../../async-gen/differential.js";
3439
import { serialize as serializeDom } from "../../async-gen/run.js";
@@ -87,26 +92,6 @@ async function freshScreen(createApp: (ctx: AppContext) => any, values: number[]
8792
}
8893
}
8994

90-
/** The memos the tree reads, directly or through other memos. */
91-
function readMemos(sc: Scenario): Set<number> {
92-
const out = new Set<number>();
93-
const add = (r: SrcRef) => {
94-
if (r.k !== "m" || out.has(r.i)) return;
95-
out.add(r.i);
96-
sc.memos[r.i].deps.forEach(d => add(d.src));
97-
};
98-
const walk = (n: Node) => {
99-
if (n.t === "leaf") [...n.text, ...n.attrs].forEach(r => add(r.src));
100-
else if (n.t === "group") n.kids.forEach(walk);
101-
else {
102-
if (n.t === "show") add(n.when.src);
103-
walk(n.child);
104-
}
105-
};
106-
walk(sc.tree);
107-
return out;
108-
}
109-
11095
async function runCase(
11196
i: number
11297
): Promise<{ sc: Scenario; findings: Finding[]; screens: string[]; final: string }> {
@@ -170,8 +155,14 @@ async function runCase(
170155
guard("throw", flush);
171156
};
172157

158+
// Each memo's hydration id, taken just before it is created.
159+
const ids = new Map<string, string>();
173160
const ctx: AppContext = {
174161
values,
162+
id(name) {
163+
const owner = getOwner();
164+
if (owner && !ids.has(name)) ids.set(name, String(peekNextChildId(owner)));
165+
},
175166
ask(name, v, poison) {
176167
// Hydration's dry run swaps the global Promise for a mock: that run's
177168
// flight is never consumed, so it is not an ask.
@@ -206,10 +197,11 @@ async function runCase(
206197
}
207198
await drain();
208199
hydrating = false;
209-
// A memo the page never reads is never streamed (the server answers
210-
// what the render waited on), so its client ask is not a refetch.
211-
const read = readMemos(sc);
212-
const refetched = asks.filter(a => read.has(Number(a.slice(1, a.indexOf(":")))));
200+
// Only an answer the payload carried can be re-asked.
201+
const payload = shell + chunks.join("");
202+
const served = (name: string) =>
203+
ids.has(name) && payload.includes(`_$HY.r["${ids.get(name)}"]`);
204+
const refetched = asks.filter(a => served(a.slice(0, a.indexOf(":"))));
213205
if (refetched.length) findings.push({ law: "refetch", step, detail: refetched.join(",") });
214206
const hydrated = serialize(container);
215207
screens.push(hydrated);

‎scripts/size/floor-caps.json‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
11
{
22
"signals: core floor (createSignal/Memo/Effect/Root/flush)": {
33
"cap": "7.43 KB",
4-
"minified": 19907
4+
"minified": 19908
55
},
66
"app: render + one signal (the simple-app floor)": {
7-
"cap": "9.79 KB",
8-
"minified": 26738
7+
"cap": "9.78 KB",
8+
"minified": 26739
99
},
1010
"app: hydrating (no stores) with Show/For/Loading/Errored/lazy": {
11-
"cap": "18.72 KB",
12-
"minified": 53566
11+
"cap": "18.74 KB",
12+
"minified": 53585
1313
},
1414
"page: base server components (hydrating + dynamic + frames + sf reference)": {
15-
"cap": "33.68 KB",
16-
"minified": 101586
15+
"cap": "33.66 KB",
16+
"minified": 101605
1717
},
1818
"page: live server components (base + live/GET + action + isPending/latest)": {
19-
"cap": "38.75 KB",
20-
"minified": 117124
19+
"cap": "38.74 KB",
20+
"minified": 117143
2121
},
2222
"server: floor (getRequestEvent + isServer)": {
2323
"cap": "1.29 KB",

0 commit comments

Comments
 (0)