[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
维护者通常 1 天内回复
评估
- 难度
- 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
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
- Click 1. refresh and let it land (
all | a). - Click 2. add:
all | a,z. - 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 分钟
- 30 天内合并 PR
- 365
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/solid 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 1 天内回复
-
难度 1/5 1-3 小时 新手友好度 88/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
-
难度 5/5 一周以上 新手友好度 38/100
维护者通常 1 天内回复
-
[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 handles可能已有人在做 @MilindChatrabhuji 于 2 天前认领。 未关闭
难度 4/5 3-5 天 新手友好度 25/100
维护者通常 1 天内回复
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 69/100
activepieces/activepieces#17974 · 1 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 66/100
OHDSI/Data2Evidence#3777 ·
维护者通常 3 天内回复
-
bug enhancement
难度 1/5 1 小时以内 新手友好度 90/100
AOSSIE-Org/PictoPy#1802 · 2 条评论 ·
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
Termix-SSH/Plugin-Snippets#26 · 1 条评论 ·
维护者通常 1 天内回复
-
agent-reported bug from-app needs-triage
难度 2/5 1-3 小时 新手友好度 72/100
nightly-labs/openbot#20504 ·
维护者通常 1 天内回复