2.0.0-rc.20: a memo that calls isPending()/latest() on an unrelated signal makes a branch opened by a held update read the pre-hold world; <Loading> never settles
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 5/5
- Tempo stimato
- Più di una settimana
- Idoneità per principianti
- 8/100
- Tipo di issue
- Bug
- Chiarezza
- Abbastanza chiara
- Stato di attività
- Attiva
- Stack tecnologico
- typescript
- Ambito
- frontend
Direzione di ricerca
The reproduction is the it.each block around arrive(probe), which renders a Loading root with a Show branch and runs the three probes against the chrome memo. Start by reading how isPending and latest interact with memo reads inside a held Loading boundary, then run the three probes to confirm plain read passes and the other two hang on root. Done means all three probes return rows and the held update settles, which requires understanding the signals reactivity internals, not a local edit.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
A held update (an async memo under the root <Loading>) writes session and opens <Show when={session() !== undefined}>. Inside, params is a memo that reads session and a chrome memo; chrome reads an unrelated signal plan, which is written afterwards outside the hold.
If chrome reads plan plainly, the branch reads session as "acc" and the hold lands. If chrome calls isPending(plan) or latest(plan) instead, params observes signedIn: false inside the branch whose condition already observed session !== undefined. The branch reads a lazy memo that never resolves (only reachable while signed out), and the root <Loading> stays on root forever.
Two plain reads of session on one screen disagree (the tear RULES-DERIVED.md D-27 forbids), and a display-ahead reader ends up holding the change it read ahead of (contradicts F-6: "display-ahead readers never hold the change they read ahead of").
Reproduces on rc.13, rc.20 and next@215c365 (not a regression). Related closed issues: #4010, #4426.
Steps to Reproduce
import { render } from "@solidjs/web";
import { createMemo, createSignal, isPending, Loading, latest, Show } from "solid-js";
import { expect, it } from "vitest";
const wait = (ms: number) => new Promise((r) => setTimeout(r, ms));
const NEVER = new Promise<never>(() => {});
type Probe = "plain read" | "isPending" | "latest";
async function arrive(probe: Probe): Promise<string | null | undefined> {
const [session, setSession] = createSignal<string | undefined>(undefined);
const [plan, setPlan] = createSignal(false);
const [gate, setGate] = createSignal(0);
let release: () => void = () => {};
function Page() {
// The only difference between the cases is how this memo reads `plan`.
const chrome = createMemo(() =>
probe === "isPending" ? (isPending(plan), plan()) : probe === "latest" ? latest(plan) : plan(),
);
const params = createMemo(() => ({ plan: chrome(), signedIn: session() !== undefined }));
const signedOutOnly = createMemo(() => NEVER, { lazy: true });
return (
<Show when={session() !== undefined} fallback={<i>signed out</i>}>
<b>{params().signedIn ? "rows" : signedOutOnly()}</b>
</Show>
);
}
const held = createMemo(() => {
const g = gate();
return g === 0 ? g : new Promise<number>((r) => (release = () => r(g)));
});
const el = document.createElement("div");
const dispose = render(
() => (
<Loading fallback={<i>root</i>}>
<span>{held()}</span>
<Page />
</Loading>
),
el,
);
await wait(10);
setGate(1);
setSession("acc");
await wait(5);
setPlan(true);
await wait(5);
release();
await wait(50);
const out = el.querySelector("b")?.textContent ?? el.querySelector("i")?.textContent;
dispose();
return out;
}
it.each<Probe>(["plain read", "isPending", "latest"])(
"%s of an unrelated signal upstream: the branch the hold opens reads the hold's session and the hold lands",
async (probe) => {
expect(await arrive(probe)).toBe("rows");
},
);
package.json
{
"name": "solid-repro",
"private": true,
"type": "module",
"scripts": { "test": "vitest run" },
"dependencies": {
"solid-js": "2.0.0-rc.20",
"@solidjs/web": "2.0.0-rc.20",
"@solidjs/signals": "2.0.0-rc.20"
},
"devDependencies": {
"@solidjs/vite-plugin": "3.0.0-next.54",
"jsdom": "30.1.2",
"vitest": "5.0.5"
}
}
vitest.config.ts
import solid from "@solidjs/vite-plugin";
import { defineConfig } from "vitest/config";
export default defineConfig({
plugins: [solid()],
test: { environment: "jsdom" },
});
Expected behavior
rows for all three probes: the only difference is how chrome reads an unrelated signal.
Actual behavior
plain read → rows; isPending and latest → root forever.
- Lingua principale
- TypeScript
- Stelle
- 36.2k
- Fork
- 1.1k
- Merge medio
- 11h 5m
- PR unite (30g)
- 475
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di solidjs/solid
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 28/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 12/100
I maintainer di solito rispondono entro 1 giorno
-
[2.0 / next] <Errored> recovery shows a pending memo's answer to an older input beside the new inputAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di solidjs/solid
Issue simili
-
needs-triage
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
microsoft/playwright#43875 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
feature
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
calagopus/panel#285 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 Meno di un'ora Idoneità per principianti 88/100
adobe/react-spectrum#10909 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Run the dependency drift checkForse già presa @spaceninja l’ha presa oggi. Aperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
cloudfour/lighthouse-parade#449 ·
I maintainer di solito rispondono entro 1 giorno