[2.0 / next] A rejection under an armed <Loading on> reveals a stale value and commits a write held outside it
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 18/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- javascript, typescript
- 领域
- frontend
调研方向
Start with the reproduction spec in packages/web/test/, which uses render, createMemo, and <Loading on={...}> inside <Errored>, and run it with npx vitest run. The fifth frame is the one to explain: it shows a0 beside s1=2 while the write is held. Trace how Loading and Errored decide which frame to show when a memo rejects during a held transition. Done means the spec passes and the expected frames hold, which probably requires a maintainer decision on the intended semantics first.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
a0 and a1 both ask by s1. a1 is read outside a <Loading on={s0()}>, and a0 and s1 are read inside it. A handler writes s0 and s1 together, so the boundary re-arms and the s1 write is held on a1, which is read outside.
When a0's new question rejects while a1's is still out, the boundary drops its fallback and shows a0=10, the answer for s1 = 0, beside s1=2. Next to it, a1 still shows 11, its answer for s1 = 1. So one frame shows three different values of s1. The frame becomes error only when a1:2 lands.
Found by checking every frame of generated ryansolid/reactivescript programs, compiled onto Solid, against F-1.
Your Example Website or App
The vitest spec below (in packages/web/test/), on next @ 77be406ca.
Steps to Reproduce the Bug or Issue
import { render } from "@solidjs/web";
import { createMemo, createSignal, Errored, flush, Loading } from "solid-js";
import { expect, it } from "vitest";
const tick = async () => { for (let i = 0; i < 2; i++) { await new Promise(r => setTimeout(r, 0)); flush(); } };
it("a rejection under an armed <Loading on> does not reveal a stale value or commit a held write", async () => {
const flights = new Map<string, { resolve: (v: number) => void; reject: (e: Error) => void }>();
const ask = (key: string) => new Promise<number>((resolve, reject) => flights.set(key, { resolve, reject }));
const [s0, setS0] = createSignal(0);
const [s1, setS1] = createSignal(0);
const el = document.createElement("div");
const frames: string[] = [];
const dispose = render(() => {
const a0 = createMemo(() => ask("a0:" + s1()));
const a1 = createMemo(() => ask("a1:" + s1()));
return (
<Errored fallback={<p>error</p>}>
<p>[a1={a1()}]</p>
<Loading on={s0()} fallback={<p>loading</p>}>
<p>[a0={a0()}]</p>
<p>[s1={s1()}]</p>
</Loading>
</Errored>
);
}, el);
await tick();
flights.get("a1:0")!.resolve(9); flights.get("a0:0")!.resolve(10); await tick(); frames.push(el.textContent!);
setS0(1); setS1(1); flush(); await tick(); frames.push(el.textContent!);
flights.get("a1:1")!.resolve(11); await tick(); frames.push(el.textContent!);
setS0(2); setS1(2); flush(); await tick(); frames.push(el.textContent!);
flights.get("a0:2")!.reject(new Error("boom")); await tick(); frames.push(el.textContent!);
flights.get("a1:2")!.resolve(12); await tick(); frames.push(el.textContent!);
dispose();
expect(frames).toEqual([
"[a1=9][a0=10][s1=0]",
"[a1=9][a0=10][s1=0]",
"[a1=11]loading",
"[a1=11]loading",
"[a1=11]loading", // received "[a1=11][a0=10][s1=2]"
"error",
]);
});
npx vitest run in packages/web. The fifth frame is [a1=11][a0=10][s1=2]. The same happens when the outside reader is wrapped in <Show when={s1() > 0}>.
Expected behavior
While the s1 = 2 write is held, the boundary keeps its fallback and s1 is not committed (F-2, F-5). The rejection is an answer for s1 = 2, and it shows when a value for that question would (F-12, D-41). In no frame does a0 show its answer for s1 = 0 beside s1=2.
Platform
- OS: macOS
- Browser: n/a (jsdom)
- Version: solid-js 2.0.0-rc.20,
next@ 77be406ca
- 主要语言
- TypeScript
- 星标
- 36.2k
- 派生
- 1.1k
- 平均合并
- 10 小时 39 分钟
- 30 天内合并 PR
- 500
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/solid 的其他 Issue
-
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
难度 3/5 1-2 天 新手友好度 55/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
[2.0 / next] Optimistic todo list with an "N left" memo loops forever when a toggle's save lands未关闭
难度 5/5 一周以上 新手友好度 15/100
维护者通常 1 天内回复
-
[2.0 / next] createOptimisticStore: add, delete, add with saves pending hands <For> an undefined row未关闭
难度 4/5 3-5 天 新手友好度 25/100
维护者通常 1 天内回复
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
ready-for-agent
难度 2/5 1-3 小时 新手友好度 72/100
LucasSantana-Dev/Lucky#2951 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 75/100
danielmiessler/LifeOS#2567 ·
维护者通常 9 天内回复
-
refactor(react-pi): classify base64 images with core's parseBase64可能已有人在做 @jimmyallinai 今天认领。 未关闭maintenance
难度 2/5 1-3 小时 新手友好度 62/100
assistant-ui/assistant-ui#10293 · 2 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 70/100
brijeshb42/monaco-vim#175 ·