Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

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

Chiusa
#4,142 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
48/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
typescript
Ambito
frontend

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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].

Lingua principale
TypeScript
Stelle
36.1k
Fork
1.1k
Merge medio
11h 37m
PR unite (30g)
344

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di solidjs/solid

Tutte le issue di solidjs/solid

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.