[2.0 RC20] Development attribution can trigger context errors by evaluating lazy children getters
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 35/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- javascript, typescript
- 领域
- devtools
调研方向
The comparator is shallowEquivalent in packages/signals/src/core/attribution.ts, which reads property values directly and so invokes getters on both previous and next output; it is shared by UNSTABLE_MEMO_OUTPUT and UNSTABLE_LIST_IDENTITY. Start by running the minimal repro with node --conditions=development repro.mjs and confirm it prints 2 when attribution is enabled. Done when the repro prints 0 and the comparator no longer evaluates lazy getters.
由索引模型根据 Issue 内容生成。
描述
What happened?
While porting a base ui to Solid 2, I encountered context errors in development previews for simple components. Their component tests were passing, which initially made this look like a problem with the preview setup or our Solid adaptations.
After reducing the failing case, I found that attribution’s output comparison was evaluating a lazy children getter that the application had not read. When that getter constructs JSX or reads context, the diagnostic can run it outside the expected owner and cause a context error.
I originally encountered this on RC13 and confirmed that the underlying behavior still reproduces with the unpatched RC20 package. The reproduction below requires neither our component library nor JSX.
Minimal reproduction
Install @solidjs/[email protected], save this as repro.mjs, and run node --conditions=development repro.mjs:
import {
createEffect,
createMemo,
createRoot,
createSignal,
flush
} from "@solidjs/signals";
import { attribution } from "@solidjs/signals/attribution";
let reads = 0;
let update;
attribution.enable({ log: false });
const dispose = createRoot(dispose => {
const [version, setVersion] = createSignal(0);
update = () => setVersion(v => v + 1);
const record = createMemo(() => {
version();
return {
get children() {
reads++;
return "child";
}
};
});
createEffect(record, () => {});
return dispose;
});
try {
flush();
update();
flush();
console.log(reads);
} finally {
attribution.disable();
dispose();
}
Expected behavior
reads remains 0: neither the application nor the effect reads children. Enabling development diagnostics should not introduce execution of that lazy getter.
Actual behavior
The example prints 2. Without attribution enabled, it prints 0.
The counting getter demonstrates the unexpected execution without throwing. In the original component previews, the getter performs context-dependent work, so that extra execution can interrupt rendering with an ownership or missing-context error.
Investigation
shallowEquivalent in packages/signals/src/core/attribution.ts compares property values directly. This invokes getters on both the previous and next output. Array-index getters are affected too.
The comparator is shared by UNSTABLE_MEMO_OUTPUT and UNSTABLE_LIST_IDENTITY.
- 主要语言
- 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
-
needs-area
难度 2/5 1-3 小时 新手友好度 68/100
Azure/typespec-azure#5936 ·
维护者通常 1 天内回复
-
难度 2/5 半天 新手友好度 72/100
vercel-labs/scriptc#2910 ·
维护者通常 1 天内回复
-
automation missing-model model-sync provider:fireworks-ai
难度 2/5 1-3 小时 新手友好度 72/100
anomalyco/models.dev#12458 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复