Skip to content

Commit 33f862f

Browse files
ryansolidclaude
andauthored
Pin Solid main c467fcd7f (engine refactor #5137, #5140; #5097 fixed); repro for solidjs/solid#5146 (#90)
#5097's fix (a server projection over a pending store waits for it) makes the projection hydrate as an answer of its own, and the hydrated client projection then stops following its source (#5146, ref/oracle/repros/proj-hydrate). So the server runtime keeps creating the guess layer for its owner slot only and rendering the truth. ref, oracle and compiled 135/135, ssr 128 (7 skip), types 181, crate 372/372. Board reference and probe 6 grade as on 99db9bce4. Claude-Session: https://claude.ai/code/session_0117BoWLtkg281f1NkGEDjCt Co-authored-by: Claude <noreply@anthropic.com>
1 parent 6a15093 commit 33f862f

5 files changed

Lines changed: 27 additions & 3 deletions

File tree

‎ref/SOLID_NEXT‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
99db9bce45b94b07bb790f04bb3f0eff6844b562
1+
c467fcd7f9f0ded3e6158409c9c148ece79e1aa1

‎ref/compile/rt-server.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export function createApp(opts: { api?: Record<string, (...a: any[]) => unknown>
141141
question(name: string, compute: (prev: unknown) => unknown, o: { loadingValue?: unknown } | undefined, mode: { optimistic: boolean; structured: boolean; derived?: boolean; record?: boolean; plain?: boolean }, key?: string): [Acc, Writer] {
142142
const fn = named(name, compute);
143143
const derive = (draft: any) => { const r = fn(draft); if (r instanceof Flight || r instanceof Promise) return (async () => landDraft(draft, r instanceof Flight ? await r.first : await r, key))(); return landDraft(draft, r, key); };
144-
if (mode.optimistic && mode.structured && mode.plain && !mode.derived) { const [truth] = (createStore as any)(derive, key && !mode.record ? [] : {}, key ? { key } : undefined); (createOptimisticStore as any)(() => (key && !mode.record ? [] : {}), key && !mode.record ? [] : {}, key ? { key } : undefined); return ro(() => truth); } // the client's layer, created for its owner slot only: the server shows the truth (it has no guesses), since Solid's server runs a projection's fn at once and one over a pending store throws NotReadyError out of the component (solidjs/solid#5097)
144+
if (mode.optimistic && mode.structured && mode.plain && !mode.derived) { const [truth] = (createStore as any)(derive, key && !mode.record ? [] : {}, key ? { key } : undefined); (createOptimisticStore as any)(() => (key && !mode.record ? [] : {}), key && !mode.record ? [] : {}, key ? { key } : undefined); return ro(() => truth); } // the client's layer, created for its owner slot only: the server shows the truth (it has no guesses). A server layer over the pending truth would hydrate as an answer of its own, and the client's layer would stop following the truth (solidjs/solid#5146)
145145
if (mode.optimistic && mode.structured) { const [store] = (createOptimisticStore as any)(derive, key && !mode.record ? [] : {}, key ? { key } : undefined); return ro(() => store); }
146146
if (mode.optimistic && mode.derived) { const [get] = createOptimistic(fn as any, o as any); return ro(get as Acc); } // AC-3 over an equation: the client's createOptimistic(fn), so the owner trees (and hydration keys) match
147147
if (mode.optimistic) { const [truth] = createSignal(fn as any, o as any); const [get] = createOptimistic(() => (truth as Acc)()); return ro(get as Acc); }
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { createStore, createOptimisticStore, Loading } from "solid-js";
2+
export function App(props) {
3+
const [truth, setTruth] = createStore(async () => await props.ask("rows"), [], { key: "id" }); // the source of truth
4+
const [view] = createOptimisticStore(() => truth, [], { key: "id" }); // guesses laid over it
5+
props.expose({ rename: t => setTruth(d => { d[0].t = t; }) });
6+
return <Loading fallback={<p>loading</p>}><p>{view.map(r => r.t).join(",")}</p></Loading>;
7+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// node repros/proj-hydrate/run.mjs (from ref/oracle)
2+
// createOptimisticStore(() => truth) over an async createStore. The server renders "A,B". In the browser, the truth is
3+
// solidjs/solid#5146
4+
// written (rename "Y"). Rendered on an empty page: "Y,B". Hydrated from the server's page: does the view follow?
5+
import { harness, wait } from "../_hydrate.mjs";
6+
const rows = [{ id: 1, t: "A" }, { id: 2, t: "B" }];
7+
const h = await harness(new URL(".", import.meta.url).pathname, () => Promise.resolve(structuredClone(rows)));
8+
for (const mode of ["hydrate", "render"]) {
9+
const page = await h.open(mode);
10+
page.on("pageerror", e => console.log("pageerror", e.message));
11+
await page.evaluate(m => window.repro.start(m), mode); await wait(30);
12+
if (mode === "render") { await page.evaluate(r => window.repro.land("rows", r), rows); await wait(60); }
13+
const before = await page.evaluate(() => window.repro.text());
14+
await page.evaluate(() => window.repro.call("rename", "Y")); await wait(60);
15+
console.log(mode.padEnd(8), `shows "${before}"`, `· after the truth's write: "${await page.evaluate(() => window.repro.text())}"`, `(expected "Y,B")`);
16+
}
17+
await h.close();

‎ref/oracle/repros/ssr-projection-over-pending-store.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Solid server: a projection over a pending async store, created in a component body with <Loading> below it, throws
1+
// FIXED in solid main fc0dac0cd (its follow-up is solidjs/solid#5146, repros/proj-hydrate). Solid server: a projection over a pending async store, created in a component body with <Loading> below it, throws
22
// NotReadyError out of renderToStream; the client build shows the fallback, then "A". Run from ref/: node oracle/repros/ssr-projection-over-pending-store.mjs (solidjs/solid#5097)
33
import { createStore, createProjection, Loading, For, createComponent } from "solid-js";
44
import { renderToStream } from "@solidjs/web";

0 commit comments

Comments
 (0)