[2.0 rc.15] Reading lazy memo in both side of conditional expression causes infinite computation loop
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 48/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- typescript
- 领域
- frontend
调研方向
Start by reading the createMemo documentation linked in the issue and tracing how lazy memo subscriptions behave when a memo is read in both a conditional expression's condition and its selected value. Reproduce the loop with the linked playground and inspect the relevant reactivity implementation and tests. Done means the memo does not recompute repeatedly after yielding a value, while still recomputing when unused or when a dependency changes.
由索引模型根据 Issue 内容生成。
描述
Describe the bug
Conditions:
- The memo should be
lazy. - The expression should be conditional.
[memo().a, memo().b]works normally. - The memo should be read in both side(condition and conditionally evaluated value) of the expression.
Then the memo gets recomputed automatically when the compute function yielded a value, leading to infinite loading.
The document for createMemo says:
lazy—boolean
When true, defers the initial computation until the value is first read, and opts the memo into autodisposal — once it has no remaining subscribers it is torn down and recomputed from scratch on the next read.
My naive guess is that the memo gets disposed before the conditionally evaluated value subscribes the memo so recomputation occurs.
Your Example Website or App
https://solid2.netlify.app/#solidjs-repl:SRn7SNNPTRCRKF9GzAEvTg
Steps to Reproduce the Bug or Issue
- Open the playground.
- Check the checkbox to start computation.
- See console, messages keep logging.
Expected behavior
The memo should not be computed again unless either it is completely unused or any of its dependencies is changed.
Screenshots or Videos
https://github.com/user-attachments/assets/1424b6c3-b7e2-4b3a-b338-34bfe45a1a6f
Platform
- OS: Windows
- Browser: Chrome 155.0.8059.40
- Solid: 2.0.0 rc.14 and rc.15
Additional context
It seems the problem exists since @solidjs/[email protected].
- 主要语言
- TypeScript
- 星标
- 36.1k
- 派生
- 1.1k
- 平均合并
- 11 小时 37 分钟
- 30 天内合并 PR
- 344
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
solidjs/solid 的其他 Issue
-
`lazy()`: remounting an already-loaded component renders empty (or the Suspense fallback) since 1.9.14可能已有人在做 @itisrmk 于 3 天前认领。 未关闭1.x
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 51/100
维护者通常 1 天内回复
-
难度 4/5 1-2 天 新手友好度 48/100
维护者通常 1 天内回复
-
难度 4/5 3-5 天 新手友好度 35/100
维护者通常 1 天内回复
-
`createRoot`'s dispose function keeps `fn` alive, so `<For>`/`<Index>` rows retain removed list items可能已有人在做 @boombang 于 5 天前认领。 未关闭1.x
难度 4/5 1-2 天 新手友好度 45/100
维护者通常 1 天内回复
相似的 Issue
-
area: app type: bug
难度 2/5 1-3 小时 新手友好度 78/100
ExpidetGames/code-reviewer#585 ·
维护者通常 1 天内回复
-
难度 1/5 1 小时以内 新手友好度 83/100
module-federation/core#5205 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 73/100
LanternOps/breeze#9392 · 1 条评论 ·
维护者通常 1 天内回复
-
engine-rs P3 review-deferral wasm
难度 2/5 1-3 小时 新手友好度 77/100
maniator/verticopolis#1154 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
维护者通常 1 天内回复