Docs: is a store proxy read inside an open setter guaranteed to return the staged value?
Les mainteneurs répondent en général sous 1 jour
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 1/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 88/100
- Type d'issue
- Documentation
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- javascript, typescript
- Domaine
- documentation
Piste de recherche
Lisez documentation/solid-2.0/04-stores.md, en particulier « Draft-first store setters », et consultez la note sur les internals du store concernant le backing en attente mentionné dans l’issue. Confirmez si les lectures du proxy pendant un setter ouvert sont un comportement prévu, puis documentez cette garantie dans le guide et/ou la TSDoc de createStore. Le travail est terminé lorsque la documentation indique clairement ce que lit store.x dans le setter et que la distinction avec les valeurs validées est sans ambiguïté.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
What this is
A documentation request about an existing 2.0 store behaviour, with a script that shows it. We hit it porting a Solid 1 app (kolu) to Solid 2.
Inside an open setter, a read through the store proxy (store.x, not draft.x) returns the value the setter has staged so far, not the last committed one. That is very useful — a helper called from inside the setter only has the store, not the draft — but we could not find it stated anywhere in the docs, so we do not know whether we may rely on it.
Version
[email protected] (latest) and [email protected] (next), Node 24, Linux. Same output on both.
Reproduction
// staged-read.js
import { createRoot, createStore, flush } from "solid-js";
let store, setStore;
createRoot(() => {
[store, setStore] = createStore({ seen: 0, rows: ["a"] });
});
// a helper that only has the store, not the draft
const seenSoFar = () => store.seen;
console.log("outside a setter: store.seen =", store.seen);
setStore((draft) => {
draft.seen = 1;
draft.rows.push("b");
console.log("inside the setter: store.seen =", store.seen);
console.log("inside the setter: store.rows =", JSON.stringify(store.rows));
console.log("inside the setter: draft.seen =", draft.seen);
console.log("inside the setter, via a helper that reads the store:", seenSoFar());
});
flush();
console.log("after the setter: store.seen =", store.seen);
// folding frames: every line reads what the lines before it staged
setStore((draft) => {
for (const n of [2, 3, 4]) {
draft.seen = store.seen + 1;
if (store.seen !== n) throw new Error(`expected ${n}, read ${store.seen}`);
}
});
flush();
console.log("after folding 3 frames: store.seen =", store.seen);
$ npm i [email protected]
$ node --conditions=browser --conditions=development staged-read.js
outside a setter: store.seen = 0
inside the setter: store.seen = 1
inside the setter: store.rows = ["a","b"]
inside the setter: draft.seen = 1
inside the setter, via a helper that reads the store: 1
after the setter: store.seen = 1
after folding 3 frames: store.seen = 4
The ask
Either:
- document it — one or two sentences under "Draft-first store setters" in
documentation/solid-2.0/04-stores.md(and/or increateStore's TSDoc), saying that while a setter is open the proxy serves the setter's staged view, sostore.xinside the callback reads what earlier lines of that callback wrote; or - say it is not a guarantee, in which case we will thread the draft through every helper instead.
Today the only statement we could find is in the store internals (the proxy serving the "pending backing" the draft mutates), which reads as an implementation note rather than a promise to users. 04-stores.md covers the draft-first setter, returning a value for a shallow replace, path-setter migration, class instances and snapshot, but says nothing about reading the store itself while a setter is open.
Why it matters to us
Code that folds incremental frames does the update in one setter and calls small helpers from inside it; those helpers close over the store, not the draft. If the staged view is a guarantee, that shape is correct and pleasant. If it is incidental, every such helper needs the draft threaded in, and we would rather change that now than after it silently starts reading committed values.
This was written by an AI agent (Claude) under a human maintainer's direction.
- Langage dominant
- TypeScript
- Étoiles
- 37k
- Forks
- 1.2k
- Merge moyen
- 8 h 43 min
- PR mergées (30 j)
- 365
Préparer son environnement
- Aucun Dockerfile ni fichier Docker Compose
- Propose un modèle de pull request
- Lire le guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de solidjs/solid
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 35/100
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 5/5 Plus d'une semaine Accessibilité débutants 38/100
Les mainteneurs répondent en général sous 1 jour
-
[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 handlesPeut-être pris @MilindChatrabhuji l’a pris il y a 2 jours. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
Les mainteneurs répondent en général sous 1 jour
-
[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)Peut-être à nouveau libre Une pull request pour cette issue a été fermée sans être fusionnée. Ouverte
Difficulté 4/5 3-5 jours Accessibilité débutants 38/100
Les mainteneurs répondent en général sous 1 jour
Toutes les issues de solidjs/solid
Issues similaires
-
agentscan:mixed-signals pending triage
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
vueuse/vueuse#5737 · 2 commentaires ·
Les mainteneurs répondent en général sous 9 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Marker-Inc-Korea/AutoRAG#2288 ·
Les mainteneurs répondent en général sous 1 jour
-
Resources: New templates of Guangzhou Metro Line 13Peut-être pris @rmt-svc l’a pris aujourd’hui. Ouverteresources
Difficulté 1/5 Moins d'une heure Accessibilité débutants 76/100
railmapgen/rmg-templates#2730 ·
Les mainteneurs répondent en général sous 1 jour
-
enhancement
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
Les mainteneurs répondent en général sous 1 jour
-
web
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour