[2.0 / next] latest() over an optimistic guess answers the re-asked truth once a re-ask lands while the guess is pending
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 55/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- javascript, typescript
- 领域
- frontend
调研方向
The issue gives a reproducer using createOptimisticStore, createOptimistic, latest(), untrack(), and refresh(), but names no source files or tests. Start by searching the repository for latest() and optimistic store tests, then reproduce the table’s sequence: keep a guess pending while a refreshed source answer lands. Done when latest() continues to read the pending guess, matching the visible store and untrack() until the action settles.
由索引模型根据 Issue 内容生成。
描述
On 2.0.0-rc.21 (next @ 2105ffb8).
A guess is pending on an optimistic store (or a createOptimistic). Its source is re-asked from outside the action and the new answer lands while the guess is still pending. The store keeps showing the guess (as #4330 intended), but latest() over it now answers the re-asked truth. Before the re-ask landed, latest() answered the guess. untrack() answers the guess throughout.
const [issues, setIssues] = createOptimisticStore(async d => { const r = await ask("fetch"); d.length = r.length; r.forEach((x, i) => { d[i] = { ...x }; }); }, [], { key: "id" });
const close = action(function* (id) {
setIssues(d => { const v = d.filter(t => t.id != id); d.length = v.length; v.forEach((x, i) => { d[i] = x; }); });
yield ask("close");
refresh(issues);
});
Steps: land fetch = [{id:1},{id:2},{id:3}]; close(1) (its close stays in flight); refresh(issues) from outside the action; land fetch = the same three rows.
| read | guess pending, before the re-ask lands | guess pending, re-ask landed | expected |
|---|---|---|---|
issues.length |
2 | 2 | 2 |
untrack(() => issues.length) |
2 | 2 | 2 |
latest(() => issues.length) |
2 | 3 | 2 |
latest(() => [...issues].map(x => ({...x}))).length |
2 | 3 | 2 |
The signal form does the same. createOptimistic(() => truth()) over createSignal(async () => ...), a guess title: "New" pending, then an outside refresh(truth) lands with "Old": detail().title and untrack say New, latest(() => detail().title) says Old.
On the screen: a tab count computed with latest(() => issues.length) shows 3 while the list under it shows 2 rows, until the close lands.
How we found it: ReactiveScript's latest x lowers to latest(), and its checker suggests latest x for a count read outside a loading on region. A fuzzed issue desk showed the count disagreeing with its own rows whenever a list refresh landed while a row close was in flight.
- 主要语言
- TypeScript
- 星标
- 36.2k
- 派生
- 1.1k
- 平均合并
- 9 小时 58 分钟
- 30 天内合并 PR
- 474
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/solid 的其他 Issue
-
难度 5/5 一周以上 新手友好度 25/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 55/100
维护者通常 1 天内回复
-
1.x
难度 4/5 3-5 天 新手友好度 45/100
维护者通常 1 天内回复
-
What gets passed to the `when` prop of a `Show` still gets executed twice on SSR可能已有人在做 @brenelz 于 6 天前认领。 未关闭1.x
难度 3/5 1-2 天 新手友好度 52/100
维护者通常 1 天内回复
-
enhancement
难度 5/5 一周以上 新手友好度 35/100
维护者通常 1 天内回复
相似的 Issue
-
Navbar avatar and name stay stale after saving profile changes可能已有人在做 @alexechoi 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 76/100
marmelab/atomic-crm#416 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 76/100
epam/ai-dial-react-file-manager#99 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
canonical/craft-actions#146 ·
维护者通常 2 天内回复
-
feature-request
难度 2/5 1-3 小时 新手友好度 66/100
bluesky-social/social-app#12343 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
lucide-icons/lucide#5165 ·
维护者通常 1 天内回复