Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

[2.0 rc.15] Reading lazy memo in both side of conditional expression causes infinite computation loop

已关闭
#4,142 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 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
  1. Open the playground.
  2. Check the checkbox to start computation.
  3. 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

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

solidjs/solid 的其他 Issue

查看 solidjs/solid 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。