[2.0 rc.15] Reading lazy memo in both side of conditional expression causes infinite computation loop
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
- Issue type
- Bug
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- frontend
Research direction
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.
Written by the indexing model from the issue text.
Description
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].
- Dominant language
- TypeScript
- Stars
- 36.1k
- Forks
- 1.1k
- Avg merge
- 11h 37m
- Merged PRs (30d)
- 344
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from solidjs/solid
-
`lazy()`: remounting an already-loaded component renders empty (or the Suspense fallback) since 1.9.14Possibly taken @itisrmk claimed this 3 days ago. Open1.x
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day
-
[2.0 rc.15 + next] For row lifecycle cleanup inherits the list computation and halts on a shared-state writePossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 4/5 3-5 days Newbie friendliness 51/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 1-2 days Newbie friendliness 48/100
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Maintainers usually reply within 1 day
-
`createRoot`'s dispose function keeps `fn` alive, so `<For>`/`<Index>` rows retain removed list itemsPossibly taken @boombang claimed this 5 days ago. Open1.x
Difficulty 4/5 1-2 days Newbie friendliness 45/100
Maintainers usually reply within 1 day
Similar issues
-
Sequências em espanhol: «Atualizado em», a aba «Fila» e o valor 'pause' ainda saem em portuguêsOpen
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
melgarafael/DeskcommCRM#3104 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day
-
bug service: webapp
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Ocelot-Social-Community/Ocelot-Social#10684 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nicobailon/pi-subagents#2978 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 66/100
getsentry/sentry-conventions#732 · 1 comment ·
Maintainers usually reply within 1 day