[2.0 / main] Store lane derivations staged per key: 8 undefined, torn or stuck row repros share one branch
维护者通常 1 天内回复
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- javascript, react, typescript
调研方向
Start by reading packages/signals/src/store/store.ts at holdWithDerive (lines 1998–2010) and the pinned tests listed in the issue; the issue names packages/web/test/store-lane-staging.spec.tsx for repros W and L6. First establish the intended rule for staging a store target's lane derivation, since the issue describes this as an unresolved design question. Done means the eight repros pass while the listed regression tests remain passing.
由索引模型根据 Issue 内容生成。
描述
On main at 99db9bce4, one branch in holdWithDerive (store.ts#L1998-L2010) is behind 8 fuzz repros of undefined, duplicate, torn and stuck store rows under actions. When a pass is lane work, this branch stages a store property's write in the lane, one key at a time. Disabling the branch fixes all 8 and fails 16 pinned tests. A probe that removes it is not a fix, but it shows the 8 share one mechanism, and that settling it needs a ruling: should a store target's lane derivation be staged as one unit or per key?
What goes wrong. When a projection or derived store re-derives as lane work, each key it writes is listed on the lane and marked CONFIG_OVERRIDE on its own. Keys the lane pass does not reach keep the committed value. The same target can then hold lane values and committed values side by side, so readers see a mix that no single answer produced. The rows below are that mix, seen from different readers.
Symptoms (each repro exits 1 on main and 0 with the branch disabled)
| repro | what the screen shows |
|---|---|
| W | One projection field shows two values in one frame: [p=G] [p=o:0]. The reader outside a <Show> that the held write is closing sees the guess; the reader inside sees the old answer. A createMemo in place of the projection shows [p=G] [p=G]. |
| L6 | <For> over a keyed createProjection of a filtered createOptimisticStore runs a row whose item is undefined (Cannot read properties of undefined (reading 'id')), and reactivity halts. Steps: toggle a row out of the filter (guess), delete it in another action and refresh, then the list lands without it. |
| R5, R11 | Board shape: two keyed optimistic stores, rows moved between them, and a keyed projection over one. The projection's mapArray runs an undefined row when an answer lands (R5 after a rejected move, R11 after a path guess on a moved row). |
| R8 | Same board shape. An event handler's untracked todo.some(r => r.id === 3) throws after a reverse, a rename and a toggle. |
| R4L-2 | A row moved out and back, where the second move writes the answer signals instead of calling refresh(). Both stores stay isPending() === true forever, and a later delete is lost. |
| R4L-6 | Three stores with rows lent between them. One store never shows its own landed row, and two stay isPending() after a final refresh. |
| R4L-9 | createStore(fn) over a keyed optimistic store reads 3d'2,3d'2 (row 3 twice, row 4 gone) until the last re-ask lands. |
W and L6 are web specs with compiled JSX (below). The other six use only solid-js primitives (createOptimisticStore, createProjection, createStore(fn), mapArray, action, refresh), with no renderer. I can attach them if useful.
Probe: false && in front of the laneStageHook && lane !== null && ... condition. All 8 repros flip to passing. packages/signals goes from 7242 passed to 16 failed and 7226 passed:
derived-store-lane-derive.test.ts: store: a derive over latest() shows the action's value nowprojection-lane-length-4631.test.ts(#4631): both "declined first" casesprojection-second-guess-4629.test.ts(#4629): the three "through a keyed projection" casesshow-stale-child-in-action-4137.test.ts(#4137): a derived record drops the action's row while the list keeps itstore/derived-store-heal-4451.test.ts(#4451): three casesswitch-under-guess-holds.test.ts: "fetch read first, through a projection", in all four build modesunread-derive-midflight-mount-4491.test.ts(#4491): storeJSON and storeKeys as the memo form
Those tests pin the reason the branch exists. A display-ahead read of a projection is lane work, and its value should be the lane's derivation, as a memo's would be (D-25). The 8 repros are what happens when only some keys of the target take that path.
Question: should a lane derivation of a store target be staged and committed as one unit, so all of its keys come from one pass? Or is per-key staging intended, with the readers (mapArray, For, some, createStore(fn)) expected to cope with a mixed target? Either answer would let the 8 be fixed against a rule.
spec (W and L6), as packages/web/test/store-lane-staging.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("W: one projection field shows one value in a frame, inside and outside a closing <Show>", async () => {
const d = desk();
let act!: (x: number) => void;
const app = mount(() => {
const [s, setS] = createSignal(0);
const [o, setO] = createOptimistic(() => d.ask("o:" + s()));
const p = createProjection<{ n: any }>(draft => void (draft.n = o()), { n: 0 });
act = action(function* (x: number) {
setS(x);
setO("G");
yield d.ask("save");
});
return (
<div>
[p={p.n}]{" "}
<Show when={s() < 2}>
<span>[p={p.n}]</span>
</Show>
</div>
);
});
flush();
await tick();
await d.drain();
act(2);
flush();
await tick();
const mid = app.frame();
await d.drain();
app.dispose();
expect(new Set([...mid.matchAll(/\[p=([^\]]*)\]/g)].map(m => m[1])).size, mid).toBe(1);
});
test("L6: <For> over a keyed projection of an optimistic list does not read an undefined row", async () => {
const d = desk();
const errors: string[] = [];
const origError = console.error;
console.error = (...a: any[]) => void errors.push(String(a[0]) + " " + String(a[1]?.message ?? ""));
let tog!: (i: number, v: boolean) => void, del!: (id: number) => void;
const app = mount(() => {
const [rows, setRows] = createOptimisticStore<{ id: number; t: string; d: boolean }[]>(
() => d.ask("list"),
[],
{ key: "id" }
);
const openList = createMemo(() => rows.filter(x => !x.d));
const open = createProjection(() => openList(), [], { key: "id" });
tog = action(function* (i: number, v: boolean) {
setRows(dr => void (dr[i].d = v));
yield d.ask("tog");
});
del = action(function* () {
yield d.ask("del");
refresh(rows);
});
return (
<Loading fallback="loading">
<p>
open:<For each={open}>{y => <i><{y.id}{y.t}></i>}</For>
</p>
</Loading>
);
});
flush();
await tick();
await d.land("list", [{ id: 1, t: "c", d: false }]);
tog(0, true);
await tick();
del(1);
await tick();
await d.land("del", 0);
const got = app.frame();
await d.land("list", []);
await d.land("tog", 0);
const end = app.frame();
app.dispose();
console.error = origError;
expect({ got, end, errors }).toEqual({ got: expect.not.stringContaining("undefined"), end: "open:", errors: [] });
});
How it was found: differential fuzzing of Solid against the ReactiveScript spec interpreter. The 8 repros came from separate rounds and were grouped by probing each candidate branch 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 天内回复