[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

オープン
#5,253 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

@yumemi-thomas がすでに取り組んでいます。

2026年11月28日 から。

  • #5254 @yumemi-thomas による — オープン

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
35/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
停滞
技術スタック
javascript, typescript
領域
frontend

調査の方向性

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.

索引モデルが issue の本文から書いたものです。

説明

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().

主要言語
TypeScript
スター
37k
フォーク
1.2k
平均マージ
8時間 43分
マージ済み PR(30日)
365

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

solidjs/solid のほかの issue

solidjs/solid の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。