[signals] A guess that mounts a row reading a failed createOptimistic re-asks it, and the guess waits for that re-ask
Los mantenedores suelen responder en 1 día
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 22/100
- Tipo de issue
- Error
- Claridad
- Bastante claro
- Estado de actividad
- Activo
- Stack tecnológico
- javascript, typescript
- Área
- frontend
Línea de trabajo
The reproduction is a vitest test that uses render, For, Errored, Loading, createOptimistic and createSignal(async) from solid. Start by running that test and reading how an optimistic layer over a failed async signal re-runs its source when a new row mounts. The fix needs the reactive core, so done means the guess shows at once while b is still failed, and the test's asks list holds only move:2.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
On main (signals unchanged since 30e7805eb), take two lists, each a createSignal(async) with a createOptimistic(() => truth()) layer over it. List b has failed. Each row of list a reads a memo over b inside its own Errored. Then a guess on a that gives a row a new object makes For mount a new row. That row's read of the memo re-runs b's async function: a second request goes out, though nothing asked for it. The guess then stays off screen until that request answers. If the request fails again, the guess shows.
When b is a plain createSignal(async) with no optimistic layer, the same test passes: there is no re-ask and the guess shows at once.
We found this through a board app. A move guess didn't show while another column had failed, and a detail pane beside it tore: its id was the new selection, its title the old one.
/**
* @jsxImportSource @solidjs/web
* @vitest-environment jsdom
*/
import { test, expect } from "vitest";
import { For, Loading, Errored, action, createMemo, createSignal, createOptimistic, flush } from "solid-js";
import { render } from "../src/index.js";
const tick = async () => { for (let i = 0; i < 4; i++) { await new Promise(r => setTimeout(r, 0)); flush(); } };
type C = { id: number };
test("a guess that mounts a row reading a failed optimistic signal re-asks it and is held on that re-ask", async () => {
const asks: any[] = [];
const ask = (k: string) => new Promise<any>((res, rej) => asks.push({ k, res, rej }));
const find = (k: string) => asks.splice(asks.findIndex(a => a.k === k), 1)[0];
const [aT] = createSignal<C[]>(async () => await ask("a"));
const [a, guessA] = createOptimistic(() => aT());
const [bT] = createSignal<C[]>(async () => await ask("b"));
const [b] = createOptimistic(() => bT()); // b has a guess layer too; no guess is ever made on it
const full = createMemo(() => b().length >= 3);
const toFront = action(function* (id: number) {
guessA(rs => [{ id }, ...rs.filter(x => x.id != id)]); // a new object for the row, so For mounts a new row
yield ask(`move:${id}`);
});
const c = document.body.appendChild(document.createElement("div"));
render(() => <Loading fallback="L">
<For each={a()}>{r => <i>{r.id}<Errored fallback="-"><b>{full() ? "full" : "ok"}</b></Errored></i>}</For>|
<Errored fallback="b failed">{b().length}</Errored>
</Loading>, c);
await tick();
find("a").res([{ id: 1 }, { id: 2 }]); await tick();
find("b").rej(new Error("declined")); await tick();
expect(c.textContent).toBe("1-2-|b failed");
toFront(2); await tick();
expect(asks.map(x => x.k)).toEqual(["move:2"]); // actual: ["move:2", "b"]: the new row's read of `full` re-asks b
expect(c.textContent).toBe("2-1-|b failed"); // actual: "1-2-|b failed": the guess waits for that re-ask
// once the re-ask fails again, the guess shows: "2-1-|b failed"
});
Replace const [b] = createOptimistic(() => bT()) with const b = bT and the test passes.
- 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