[2.0 / next] createOptimisticStore(fn) swallows the error when fn reads a failed async memo (createStore delivers it)
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 55/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- javascript, typescript
- Ambito
- frontend
Direzione di ricerca
Start with the createOptimisticStore implementation and the related createStore error handling, then add the supplied reproduction under packages/signals/tests. Compare the await, memo-async, and memo-sync cases to see where the rejection is lost. Done means all six cases report ERR timeout, matching the expected output.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
A derived createOptimisticStore(fn, [], { key }) whose fn reads an async createMemo never reports that memo's rejection: readers keep the last value, with no error and no pending. The same fn under createStore delivers the error, and so does createOptimisticStore when fn awaits the promise itself.
Found at next 5e68925c (2.0.0-rc.20): a ReactiveScript app's list, after a failed reload, stayed on its old rows (or its Loading fallback) instead of showing the Errored fallback.
Repro (packages/signals/tests)
import { it } from "vitest";
import { createEffect, createMemo, createOptimisticStore, createStore, createRoot, createSignal, flush } from "../src/index.js";
const tick = async () => { for (let i = 0; i < 4; i++) { await new Promise(r => setTimeout(r, 0)); flush(); } };
for (const kind of ["optimistic", "store"]) for (const form of ["await", "memo-async", "memo-sync"])
it(`${kind} over a failing loader, ${form}`, async () => {
const asks: { key: string; res: (v: any) => void; rej: (e: any) => void }[] = [];
const ask = (key: string) => new Promise<any>((res, rej) => asks.push({ key, res, rej }));
const settle = async (key: string, f: (a: any) => void) => { for (const a of asks.filter(a => a.key === key)) { asks.splice(asks.indexOf(a), 1); f(a); } await tick(); };
const frames: string[] = []; let setFilter!: (f: string) => void;
createRoot(() => {
const [filter, sf] = createSignal("open"); setFilter = sf;
const m = createMemo(() => ask(`f:${filter()}`));
const make: any = kind === "store" ? createStore : createOptimisticStore;
const write = (d: any[], r: any) => { d.length = 0; d.push(...r.map((x: any) => ({ ...x }))); };
const [issues] = make(form === "memo-sync" ? (d: any[]) => { write(d, m()); }
: async (d: any[]) => { write(d, form === "memo-async" ? m() : await ask(`f:${filter()}`)); }, [], { key: "id" });
createEffect(() => (issues as any[]).map(i => `#${i.id}`).join(" "),
{ effect: (v: string) => { frames.push(v); }, error: (e: any) => { frames.push(`ERR ${e?.message ?? e}`); } } as any);
});
await tick();
await settle("f:open", a => a.res([{ id: 1 }, { id: 3 }]));
setFilter("closed"); flush(); await tick();
await settle("f:closed", a => a.rej(new Error("timeout")));
console.log(`${kind} ${form}: ` + frames.join(" | "));
});
Output
optimistic await: #1 #3 | ERR timeout
optimistic memo-async: #1 #3 <- error lost
optimistic memo-sync: #1 #3 <- error lost
store await: #1 #3 | ERR timeout
store memo-async: #1 #3 | ERR timeout
store memo-sync: #1 #3 | ERR timeout
Expected
ERR timeout in all six. Reading a failed memo inside the optimistic store's derive should error the store, as it does for createStore.
Related, both closed: #4271 (a keyed createProjection over a memo swallows later errors) and #4364.
- Lingua principale
- TypeScript
- Stelle
- 36.2k
- Fork
- 1.1k
- Merge medio
- 11h 48m
- PR unite (30g)
- 441
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à 3/5 1-2 giorni Idoneità per principianti 52/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 58/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 52/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di solidjs/solid
Issue simili
-
area:cli bug P4
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
bug from-studio
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
esengine/DeepSeek-Reasonix#14868 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
linxiv-dev/linXiv#384 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
scope:core type:security
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
I maintainer di solito rispondono entro 1 giorno
-
follow-redirects updateAperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
mailgun/mailgun.js#544 ·