[signals] A guessed row remounts when the truth lands from a local source store, even with the same id
维护者通常 1 天内回复
评估
- 难度
- 4/5
- 预计耗时
- 1-2 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- frontend
调研方向
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.
由索引模型根据 Issue 内容生成。
描述
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.
- 主要语言
- 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
-
agentscan:mixed-signals pending triage
难度 2/5 1-3 小时 新手友好度 82/100
维护者通常 9 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
Marker-Inc-Korea/AutoRAG#2288 ·
维护者通常 1 天内回复
-
Resources: New templates of Guangzhou Metro Line 13可能已有人在做 @rmt-svc 今天认领。 未关闭resources
难度 1/5 1 小时以内 新手友好度 76/100
railmapgen/rmg-templates#2730 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
web
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复