[2.0] A long memo chain overflows the stack in the commit/settle path

Chiusa
#4,587 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
22/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
javascript, typescript
Ambito
frontend

Direzione di ricerca

The bug is in the commit and settle walks, including settlePendingSource and the staged-error marking, which recurse once per memo node in the reactive graph. Start by reading those functions in the reactive core and reproducing with a warm-built chain of about 8,000 memos over a rejecting async source. Done means the walks are iterative with an explicit stack and the error surfaces as E:boomA at that depth.

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

Descrizione

bug

What happens

A chain of createMemo nodes over an async source, read under <Errored> with isPending, overflows the call stack in the commit/settle path once the chain is long enough.

  • On next, a warm-built chain of about 8,000+ memos surfaces E:Maximum call stack size exceeded as the rendered error, in place of the source's own error.
  • With #4582 (the settle walk also stage-marks chain nodes via stageMark), the walk recurses through chains too. At about 15,000 nodes it silently drops the staged E:boomA frame instead of erroring.

Real apps rarely build chains this deep, but the error should be the source's (boomA), never a stack overflow, and a frame should never be dropped without an error.

Repro shape

  1. Make an async source that rejects with new Error("boomA").
  2. Build a chain of N createMemo nodes, each reading the previous one, after the source has a first value (warm build).
  3. Read the last memo under an Errored boundary, together with isPending(last), in a render effect that records frames.
  4. Trigger the rejecting flight and flush.

With N ≈ 8,000 on next, the recorded error is Maximum call stack size exceeded. Expected: E:boomA.

Likely fix direction

Make the commit/settle walks (including settlePendingSource and the staged-error marking) iterative with an explicit stack, instead of recursing per node.

Found during review of #4582. It doesn't block that PR, because next already fails at a shallower depth.

Lingua principale
TypeScript
Stelle
36.2k
Fork
1.1k
Merge medio
9h 56m
PR unite (30g)
487

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.