[2.0.4] A memo over an optimistic list cannot both agree with the shown rows through `latest()` and restart its request when an outside refresh lands
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 38/100
- Issue-Typ
- Bug
- Klarheit
- Klar beschrieben
- Aktivitätsstatus
- Aktiv
- Tech-Stack
- javascript, typescript
- Bereich
- frontend, performance
Rechercherichtung
Start with the repro using createOptimisticStore, createMemo, latest(), and refresh(), then read packages/signals/docs/RULES-DERIVED.md for D-34 and D-22. Compare keyed and key: null behavior against the changes attempted in #5238. Done means the intended memo semantics are decided and the keyed and null-key cases have a consistent implementation and regression tests.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
An action removes a row from a createOptimisticStore list and waits. An outside refresh() lands different rows. The list keeps showing the guess until the action ends. A memo over the list then behaves differently by key form, and each form misses one thing:
latest(createMemo(() => items.length)) in the window |
An async memo that reads items.length to choose its request |
|
|---|---|---|
| keyed | the shown length | asks again when the action ends, so its answer arrives after the commit frame could have had it |
key: null |
the refetched length (4 beside two shown rows) |
asks again when the refresh lands |
Repro (@solidjs/signals, same with solid-js):
import { createRoot, createOptimisticStore, createMemo, createRenderEffect, action, refresh, flush, latest } from "@solidjs/signals";
const settle = async () => { for (let i = 0; i < 4; i++) { await new Promise(r => setTimeout(r)); flush(); } };
for (const key of ["id", null]) {
let server = ["a", "b", "c"];
const asked = [];
let shown, latestLen;
const app = createRoot(() => {
const [rows, set] = createOptimisticStore(async () => server.map(id => ({ id })), [], { key });
const len = createMemo(() => rows.length);
const query = createMemo(async () => { asked.push(rows.length); return rows.length; }); // stands in for a request
createRenderEffect(() => [rows.length, query()], () => {});
createRenderEffect(() => latest(len), v => { latestLen = v; });
createRenderEffect(() => rows.length, v => { shown = v; });
return { rows, set };
});
await settle();
action(function* () { app.set(d => void d.shift()); yield new Promise(() => {}); })(); // the action never ends here
await settle();
server = ["a", "b", "c", "d"]; refresh(app.rows); await settle();
console.log(`key ${key}: asked ${asked.join(",")} | shown ${shown} | latest(memo) ${latestLen}`);
}
Output, the same on 2.0.4 and main (510bb8d01):
key id: asked 3,2,2 | shown 2 | latest(memo) 2
key null: asked 3,2,4 | shown 2 | latest(memo) 4
With the keyed list the request isn't asked again for the refetched rows until the action ends; with key: null it is, but latest(memo) then reads the refetched length beside the two shown rows.
Cause: a keyed list folds the truth beneath the guess and lane work keeps reading the guess; a key: null list is corrected and its lane's derivations re-derive on the truth. A memo is one node with one version, so it follows one or the other.
D-34 (packages/signals/docs/RULES-DERIVED.md) asks for both: derivations re-derive from the truth now "so downstream refetches restart at once", while the screen and latest of the displayed slot keep the guess. D-22 says a sync derivation of a held value has produced an answer, which reads as latest(memo) being the truth.
Question: which is intended for a memo over a guessed list?
latest(memo)is the truth and the request restarts at once (today'skey: null), and keyed lists should move to it; orlatest(memo)agrees with the list, and the request should still restart at once, which needs the folded lane to stage a second derivation for async work.
Folding key: null lists was tried in #5238 and removed: it gave option 2's latest and lost the immediate request.
- Vorherrschende Sprache
- TypeScript
- Sterne
- 37k
- Forks
- 1.2k
- Ø Merge
- 8 Std. 43 Min.
- Gemergte PRs (30 T.)
- 365
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Hat eine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus solidjs/solid
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 1/5 1-3 Stunden Anfängerfreundlichkeit 88/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
Maintainer antworten meist innerhalb von 1 Tag
-
[2.0.4] Nested `<Errored>`: the outer boundary stays on an error the inner one rethrew, after the next error is one the inner one handlesEvtl. vergeben @MilindChatrabhuji hat das vor 2 Tagen übernommen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
Maintainer antworten meist innerhalb von 1 Tag
-
[2.0.4] A waiting action started from a cleanup holds back an effect's write that reacts to the same landing (follow-up to #5251)Evtl. wieder frei Ein Pull Request dazu wurde ohne Merge geschlossen. Offen
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 38/100
Maintainer antworten meist innerhalb von 1 Tag
Ähnliche Issues
-
agentscan:mixed-signals pending triage
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
vueuse/vueuse#5737 · 2 Kommentare ·
Maintainer antworten meist innerhalb von 9 Tagen
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Marker-Inc-Korea/AutoRAG#2288 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Resources: New templates of Guangzhou Metro Line 13Evtl. vergeben @rmt-svc hat das heute übernommen. Offenresources
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 76/100
railmapgen/rmg-templates#2730 ·
Maintainer antworten meist innerhalb von 1 Tag
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100
Maintainer antworten meist innerhalb von 1 Tag
-
web
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 78/100
Maintainer antworten meist innerhalb von 1 Tag