[signals] A guessed row remounts when the truth lands from a local source store, even with the same id
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 48/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Stack tecnológico
- typescript
- Área
- frontend
Línea de trabajo
The issue provides a TypeScript reproduction using createOptimisticStore, createStore, and mapArray, but names no source or test file. Start by locating the optimistic store implementation and its tests, then reproduce the local source store case and compare it with the fetch plus refresh() case. Done means the same-id row mounts once and updates pending in place for both forms, while different ids still remount.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Summary
An action adds a row optimistically, then writes the saved row into the source of truth. The guess reverts and the saved row shows in the same frame, with no blink. But when the optimistic store is derived from a local store (createOptimisticStore(() => source, [])), the keyed list remounts the row, even when the saved row has the same id as the guess.
When the truth comes from a fetch instead (createOptimisticStore(async () => fetchTodos(), []) plus refresh() in the action), the same steps keep the row. It mounts once and updates in place. Only the local-source form drops it.
Found on main @ 8bfca0d while answering #5129.
Repro
const [source, setSource] = createStore<Todo[]>([]);
const [todos, setTodos] = createOptimisticStore<Todo[]>(() => source, []);
createRoot(() => {
const rows = mapArray(() => todos, row => {
console.log("mount", row.id);
createRenderEffect(() => `${row.id}:${!!row.pending}`, v => console.log("row", v));
return row;
});
createRenderEffect(() => rows().length, () => {});
});
let resolveSave!: (t: Todo) => void;
const add = action(function* (text: string) {
setTodos(t => { t.push({ id: "tmp-1", text, pending: true }); }); // guess
const saved: Todo = yield new Promise<Todo>(r => (resolveSave = r));
setSource(s => { s.push(saved); }); // truth
});
add("milk");
// flush, then:
resolveSave({ id: "tmp-1", text: "milk" }); // the server kept the client's id
Observed
| Truth | Same id |
Different id |
|---|---|---|
Local source store, setSource in the action |
mount tmp-1, then mount tmp-1 again |
remounts |
Fetch plus refresh() in the action |
one mount tmp-1; the row flips pending true → false in place |
remounts |
Every case ends on the right value.
Expected
With the same id, the guess row carries over to the saved row in both forms, as it does in the fetch form. The local form looks like it adopts source's own row proxies instead of reconciling them by key, so the guessed row is dropped and a new one is mounted.
- Lenguaje dominante
- TypeScript
- Estrellas
- 37k
- Forks
- 1.2k
- Merge medio
- 8 h 43 min
- PR fusionados (30 d)
- 365
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de solidjs/solid
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 1-3 horas Aptitud para principiantes 88/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 38/100
Los mantenedores suelen responder en 1 día
-
[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 handlesPosiblemente ocupada @MilindChatrabhuji la tomó hace 2 días. Abierto
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
Los mantenedores suelen responder en 1 día
Todos los issues de solidjs/solid
Issues similares
-
agentscan:mixed-signals pending triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
vueuse/vueuse#5737 · 2 comentarios ·
Los mantenedores suelen responder en 9 días
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Marker-Inc-Korea/AutoRAG#2288 ·
Los mantenedores suelen responder en 1 día
-
Resources: New templates of Guangzhou Metro Line 13Posiblemente ocupada @rmt-svc la tomó hoy. Abiertoresources
Dificultad 1/5 Menos de una hora Aptitud para principiantes 76/100
railmapgen/rmg-templates#2730 ·
Los mantenedores suelen responder en 1 día
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Los mantenedores suelen responder en 1 día
-
web
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
Los mantenedores suelen responder en 1 día