Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ref/SOLID_NEXT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
99db9bce45b94b07bb790f04bb3f0eff6844b562
c467fcd7f9f0ded3e6158409c9c148ece79e1aa1
2 changes: 1 addition & 1 deletion ref/compile/rt-server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ export function createApp(opts: { api?: Record<string, (...a: any[]) => unknown>
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] {
const fn = named(name, compute);
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); };
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)
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)
if (mode.optimistic && mode.structured) { const [store] = (createOptimisticStore as any)(derive, key && !mode.record ? [] : {}, key ? { key } : undefined); return ro(() => store); }
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
if (mode.optimistic) { const [truth] = createSignal(fn as any, o as any); const [get] = createOptimistic(() => (truth as Acc)()); return ro(get as Acc); }
Expand Down
7 changes: 7 additions & 0 deletions ref/oracle/repros/proj-hydrate/app.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { createStore, createOptimisticStore, Loading } from "solid-js";
export function App(props) {
const [truth, setTruth] = createStore(async () => await props.ask("rows"), [], { key: "id" }); // the source of truth
const [view] = createOptimisticStore(() => truth, [], { key: "id" }); // guesses laid over it
props.expose({ rename: t => setTruth(d => { d[0].t = t; }) });
return <Loading fallback={<p>loading</p>}><p>{view.map(r => r.t).join(",")}</p></Loading>;
}
17 changes: 17 additions & 0 deletions ref/oracle/repros/proj-hydrate/run.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// node repros/proj-hydrate/run.mjs (from ref/oracle)
// createOptimisticStore(() => truth) over an async createStore. The server renders "A,B". In the browser, the truth is
// solidjs/solid#5146
// written (rename "Y"). Rendered on an empty page: "Y,B". Hydrated from the server's page: does the view follow?
import { harness, wait } from "../_hydrate.mjs";
const rows = [{ id: 1, t: "A" }, { id: 2, t: "B" }];
const h = await harness(new URL(".", import.meta.url).pathname, () => Promise.resolve(structuredClone(rows)));
for (const mode of ["hydrate", "render"]) {
const page = await h.open(mode);
page.on("pageerror", e => console.log("pageerror", e.message));
await page.evaluate(m => window.repro.start(m), mode); await wait(30);
if (mode === "render") { await page.evaluate(r => window.repro.land("rows", r), rows); await wait(60); }
const before = await page.evaluate(() => window.repro.text());
await page.evaluate(() => window.repro.call("rename", "Y")); await wait(60);
console.log(mode.padEnd(8), `shows "${before}"`, `· after the truth's write: "${await page.evaluate(() => window.repro.text())}"`, `(expected "Y,B")`);
}
await h.close();
2 changes: 1 addition & 1 deletion ref/oracle/repros/ssr-projection-over-pending-store.mjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Solid server: a projection over a pending async store, created in a component body with <Loading> below it, throws
// 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
// 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)
import { createStore, createProjection, Loading, For, createComponent } from "solid-js";
import { renderToStream } from "@solidjs/web";
Expand Down
Loading