[2.0 / main] A guess before the first answer (S-56): crash, empty Loading hole, stuck latest() and a render that never runs
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- javascript, typescript
调研方向
Start with packages/signals/src/core/guesses.ts at optimisticWrite and inspect the two named S-56 tests in packages/signals. Then run the four repros described in packages/web/test/first-load-guess.spec.tsx and the signals suite. The issue is resolved when the expected behavior for guesses before a node’s first answer is decided and the relevant repros and tests pass.
由索引模型根据 Issue 内容生成。
描述
On main at 99db9bce4, four fuzz repros come down to S-56: a guess made on an optimistic node before its first answer shows, and the first answer judges it. The four symptoms are a crash, an empty hole in a revealed <Loading>, a render effect that never runs, and a latest() stuck on a reverted guess. Making optimisticWrite (guesses.ts#L96) ignore a guess while the node is still uninitialized fixes all four and fails the 2 tests that pin S-56.
Symptoms (each fails on main and passes with the probe)
| repro | what happens |
|---|---|
| resolveTx crash | [o, setO] = createOptimistic(() => ask("o:" + latest(s))), read only through createDeferred(() => o()). Steps: setS(2), then an action guesses o, then setS(3). The last flush throws TypeError: Cannot read properties of null (reading '_into') in resolveTx. |
| H: empty hole | q = createOptimistic(() => ask("q:" + a1())) is guessed while a1's first load is out; q is not rendered. When a1 and a2 land, <Loading> reveals [a1=] [a2=a2]: the a1 hole is empty, and a1() read outside throws NotReadyError until q lands. |
R4C-1: stuck latest |
One action guesses an async optimistic node that is still on its first load and a plain createOptimistic(0). After everything lands, the screen shows [o0=0][Lo0=30] for good, while untracked latest(o0) is 0. The stuck signal has no async of its own. |
| J: never renders | During a first load, one action writes s1, guesses o = createOptimistic(() => ask("o:" + latest(s1))) and writes s0. A render effect over q = createSignal(() => ask("q:" + latest(s0))) never runs, although q() is "q:1" and no flight is open. |
H, the crash and R4C-1 are web specs with compiled JSX (below). J uses only solid-js primitives (createRenderEffect, createOptimistic, action, latest).
Probe: at the top of optimisticWrite:
if ((n as any)._fn !== undefined && (n as Computed<T>)._statusFlags & STATUS_UNINITIALIZED) return v as T;
All four flip to passing. packages/signals goes from 7242 passed to 2 failed and 7240 passed, both S-56 pins:
createOptimistic.test.ts: refreshing an optimistic accessor does not throw upstream pending reads (#2694)uninitialized-visibility.test.ts: optimistic computed: getter throws while uninitialized; a guess before the first answer shows and the answer judges it (S-56)
Question: S-56 replaced the old OPTIMISTIC_WRITE_BEFORE_LOAD error (rc.21) with a guess that shows. These four are what that guess does to nodes around it while their own first loads are still out. Should S-56 stand, with the four fixed inside it? Or should a guess before the first answer go back to being refused, or held until the answer, which the probe approximates? The probe is not a proposed fix. It shows the four share this one entry point.
spec (H, resolveTx, R4C-1), as packages/web/test/first-load-guess.spec.tsx
/**
* @jsxImportSource @solidjs/web
* @vitest-environment jsdom
*/
import { expect, test } from "vitest";
import {
For,
Loading,
Show,
action,
createDeferred,
createMemo,
createOptimistic,
createOptimisticStore,
createProjection,
createSignal,
flush,
latest,
refresh,
untrack
} from "solid-js";
import { render } from "../src/index.js";
process.on("unhandledRejection", () => {});
const tick = async () => {
for (let i = 0; i < 4; i++) {
await new Promise(r => setTimeout(r, 0));
flush();
}
};
function desk() {
const asks: { key: string; res: (v: any) => void }[] = [];
const ask = (key: string) => new Promise<any>(res => asks.push({ key, res }));
const land = async (key: string, v: any = key) => {
const i = asks.findIndex(a => a.key === key);
if (i < 0) throw new Error(`no ask ${key}; open: ${asks.map(a => a.key)}`);
asks.splice(i, 1)[0].res(v);
await tick();
};
const drain = async () => {
for (let n = 0; n < 30 && asks.length; n++) {
for (const a of asks.splice(0)) a.res(a.key);
await tick();
}
};
return { ask, land, drain, open: () => asks.map(a => a.key).join(",") };
}
function mount(view: () => any) {
const container = document.body.appendChild(document.createElement("div"));
const dispose = render(view, container);
return {
frame: () => container.textContent!.replace(/\s+/g, " ").trim(),
dispose: () => (dispose(), container.remove())
};
}
test("H: a guess during an unrendered first load does not reveal <Loading> with an empty hole", async () => {
const d = desk();
let guess!: (x: string) => void;
const app = mount(() => {
const a1 = createMemo(() => d.ask("a1"));
const a2 = createMemo(() => d.ask("a2"));
const [, setQ] = createOptimistic(() => d.ask("q:" + a1()));
guess = action(function* (x: string) {
setQ(x);
});
return (
<Loading fallback="LOADING">
<div>
[a1={a1()}] [a2={a2()}]
</div>
</Loading>
);
});
flush();
await tick();
guess("G");
flush();
await tick();
await d.land("a1");
await d.land("a2");
const mid = app.frame();
await d.drain();
app.dispose();
expect(["[a1=a1] [a2=a2]", "LOADING"]).toContain(mid);
});
test("resolveTx: a guess during a first load read through createDeferred does not crash", async () => {
const d = desk();
const errs: string[] = [];
const origError = console.error;
console.error = (...a: any[]) => void errs.push(String(a[0]).split("\n")[0] + " " + String(a[1]?.message ?? ""));
let setS!: (v: number) => void, act!: (v: number) => void;
const app = mount(() => {
const [s, b] = createSignal(0);
setS = b;
const [o, setO] = createOptimistic(() => d.ask("o:" + latest(s)));
const f = createDeferred(() => o());
act = action(function* (v: number) {
setO("G" + v);
});
return <i>[f={f()}]</i>;
});
await tick();
for (const fn of [() => setS(2), () => act(3), () => setS(3)]) {
try {
fn();
flush();
await tick();
} catch (e: any) {
errs.push(e?.message);
}
}
try {
await d.drain();
} catch (e: any) {
errs.push(e?.message);
}
console.error = origError;
const settled = app.frame();
app.dispose();
expect({ errs, settled }).toEqual({ errs: [], settled: "[f=o:3]" });
});
test("R4C-1: latest() of a sync optimistic signal reverts when the action also guessed a first-loading node", async () => {
const d = desk();
let act!: (v: number) => void, o0!: () => number;
const app = mount(() => {
const [, setQ] = createOptimistic(() => d.ask("q0"));
const [o, setO] = createOptimistic(0);
o0 = o;
act = action(function* (v: number) {
setQ("G");
setO(v * 10);
yield d.ask("w");
});
return (
<div>
[o0={String(o())}][Lo0={String(latest(o))}]
</div>
);
});
await tick();
act(3);
flush();
await tick();
await d.drain();
await tick();
const settled = app.frame();
const untracked = untrack(() => latest(o0));
app.dispose();
expect({ settled, untracked }).toEqual({ settled: "[o0=0][Lo0=0]", untracked: 0 });
});
How it was found: differential fuzzing of Solid against the ReactiveScript spec interpreter. The four came from separate rounds and were grouped by probing candidate branches against every open repro and the signals suite.
- 主要语言
- 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 天内回复