2.0.0-rc.20: createTrackedEffect never re-runs when a dependency is written earlier in the same effect pass
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
- 28/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 reactive core: start with dist/dev.js and the tracked effect's first-run path, where the staged write is propagated before the effect links its dependency, and the staleReader / _reruns logic that does not cover EFFECT_TRACKED nodes. Run the two repro snippets in the issue to confirm the logged values are [0] instead of [0, 1]. Done when both cases log [0, 1] and the existing tracked-effect tests still pass.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Describe the bug
A createTrackedEffect whose dependency is written in the same effect pass, before the tracked effect's first run, reads the committed (old) value and never re-runs once the write commits.
Two common shapes:
- another effect writes the dependency on its first run;
- a parent's
onSettledwrites a signal passed to the child as a prop.
createEffect(compute, fn) sees the write in both cases (its effect runs again with the new value), so the difference is specific to the tracked effect. A write made by the component's own onSettled, or after the first flush, is seen.
Your Example Website or App
Self-contained repro below (no external link).
Steps to Reproduce the Bug or Issue
import { createEffect, createSignal, createTrackedEffect, flush, onSettled } from 'solid-js'
import { render } from '@solidjs/web'
// 1. Written by another effect on its first run
const log: number[] = []
function C() {
const [s, setS] = createSignal(0)
createEffect(() => 1, () => { setS(1) })
createTrackedEffect(() => { log.push(s()) })
return null
}
render(() => <C />, document.body)
flush(); await Promise.resolve(); flush()
console.log(log) // [0] — expected [0, 1]
// 2. Prop written by the parent's onSettled
const log2: number[] = []
function Child(props: { v: number }) {
createTrackedEffect(() => { log2.push(props.v) })
return null
}
function Parent() {
const [s, setS] = createSignal(0)
onSettled(() => { setS(1) })
return <Child v={s()} />
}
render(() => <Parent />, document.body)
flush(); await Promise.resolve(); flush()
console.log(log2) // [0] — expected [0, 1]
Replacing createTrackedEffect(() => log.push(s())) with createEffect(() => s(), (v) => log.push(v)) logs [0, 1] (resp. ends on 1) in both cases.
Expected behavior
The tracked effect re-runs with 1 after the write commits, as createEffect(compute, fn) does.
Screenshots or Videos
No response
Platform
- solid-js / @solidjs/signals / @solidjs/web: 2.0.0-rc.20 (client build)
- Reproduced in Chromium (Vitest Browser Mode) and jsdom
- OS: Linux
Additional context
Reading dist/dev.js: the tracked effect's first run is enqueued on the heap and runs in the user effect queue; the staged write seems to have been propagated to subscribers before the tracked effect linked its dependency, so the commit at the end of the flush notifies nobody. The stale-reader re-derivation (staleReader / _reruns) does not appear to cover EFFECT_TRACKED nodes.
Impact: in an app migrated from 1.x, this silently froze several views on their initial value (a page stuck on "loading", a PDF page indicator, tab state restored from the URL). We worked around it by converting tracked effects to createEffect(compute, fn).
- Lingua principale
- TypeScript
- Stelle
- 36.2k
- Fork
- 1.1k
- Merge medio
- 11h 5m
- PR unite (30g)
- 475
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di solidjs/solid
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 12/100
I maintainer di solito rispondono entro 1 giorno
-
[2.0 / next] <Errored> recovery shows a pending memo's answer to an older input beside the new inputAperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 20/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 15/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 5/5 Più di una settimana Idoneità per principianti 18/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 4/5 3-5 giorni Idoneità per principianti 22/100
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di solidjs/solid
Issue simili
-
🐛 bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
LibreChat-AI/LibreChat#17733 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
TypeStrong/typedoc#3150 ·
-
accessibility bug good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
I maintainer di solito rispondono entro 1 giorno
-
Normalize image-source MIME types before SVG dispatchForse già presa @HarsH-1877 l’ha presa oggi. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
tscircuit/image-utils#58 · 1 commento ·
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 74/100
I maintainer di solito rispondono entro 2 giorni