[2.0.4] After a `refresh()` of an optimistic store has landed, an input switched under a guess is no longer held with the action

Abierto
#5,253 1 comentario 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

@yumemi-thomas ya está trabajando en esto.

Desde el 28/11/2026.

  • #5254 de @yumemi-thomas — abierto

Evaluación

Dificultad
4/5
Tiempo estimado
3-5 días
Aptitud para principiantes
35/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Estancado
Stack tecnológico
javascript, typescript
Área
frontend

Línea de trabajo

Start with the provided SolidJS playground and reproduce the refresh-before-action sequence. Trace the setter landing path in store/thinProjection.ts, the _reask cleanup in core/scheduler.ts, and hold handling in store/thinOptimistic.ts. Done means changing filter after the refresh preserves the action’s hold and keeps the displayed value at all; add a regression test for that sequence.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

An optimistic store's async function reads a signal filter. An action adds a guess to the store and then waits. Switching filter while the action is out is held with the action, so the screen keeps all beside the all list and the guess. But once a refresh() of the store has landed, the same switch isn't held: filter shows open right away, beside the old list and the guess, until the action ends.

Reproduction

Playground link

import {
  createSignal,
  createOptimisticStore,
  action,
  refresh,
  Loading,
} from "solid-js";

type Todo = { id: string };
const fetchTodos = (filter: string) =>
  new Promise<Todo[]>((r) =>
    setTimeout(() => r([{ id: filter === "all" ? "a" : "b" }]), 50),
  );

export default function App() {
  const [filter, setFilter] = createSignal("all");
  const [todos, setTodos] = createOptimisticStore<Todo[]>(
    async () => await fetchTodos(filter()),
    [],
  );
  const add = action(function* () {
    setTodos((ts) => [...ts, { id: "z" }]); // the guess
    yield new Promise(() => {}); // never ends: the action stays out
  });

  return (
    <Loading>
      <button onClick={() => refresh(todos)}>1. refresh</button>
      <button onClick={() => add()}>2. add</button>
      <button onClick={() => setFilter("open")}>3. switch filter</button>
      <p>
        {filter()} | {todos.map((t) => t.id).join(",")}
      </p>
    </Loading>
  );
}

Steps

  1. Click 1. refresh and let it land (all | a).
  2. Click 2. add: all | a,z.
  3. Click 3. switch filter.

Then reload and do the same without step 1.

Expected

all | a,z after step 3, as without step 1. The switch changes the input of the store the guess sits on, so it "is held with the guess's hold until it commits" (D-34, the ruling in #4337). A refresh that already landed shouldn't change that.

Actual

after step 3
without step 1 all | a,z
with step 1 open | a,z

open | a,z stays until the action ends, even after the open request answers. It needs the guess (the same action without setTodos is held) and the store (createOptimistic is held). Same in 2.0.4 and main (510bb8d01), dev and prod.

Cause

When the refreshed store lands, it settles through the setter path (landBySetter, store/thinProjection.ts) without staging a value, so the cleanup that clears its _reask flag (core/scheduler.ts) never runs. The next filter change reads the stale flag and is treated as a quiet re-ask, so it never joins the action's hold (store/thinOptimistic.ts).

Related: a regression of #4337 (#4336) through a prior refresh().

Lenguaje dominante
TypeScript
Estrellas
37k
Forks
1.2k
Merge medio
8 h 43 min
PR fusionados (30 d)
365

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de solidjs/solid

Todos los issues de solidjs/solid

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.