[2.0 / main] A guess before the first answer (S-56): crash, empty Loading hole, stuck latest() and a render that never runs
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 5/5
- Thời gian dự kiến
- Hơn một tuần
- Mức phù hợp với người mới
- 35/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Khá rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- javascript, typescript
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- TypeScript
- Star
- 37k
- Fork
- 1.2k
- Merge trung bình
- 8 giờ 43 phút
- Pull request đã merge (30 ngày)
- 365
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của solidjs/solid
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 35/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 38/100
Maintainer thường phản hồi trong vòng 1 ngày
-
[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 handlesCó thể đã có người làm @MilindChatrabhuji đã nhận 2 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của solidjs/solid
Issue tương tự
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 69/100
activepieces/activepieces#17974 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 66/100
OHDSI/Data2Evidence#3777 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug enhancement
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 90/100
AOSSIE-Org/PictoPy#1802 · 2 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 75/100
Termix-SSH/Plugin-Snippets#26 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
agent-reported bug from-app needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
nightly-labs/openbot#20504 ·
Maintainer thường phản hồi trong vòng 1 ngày