-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Hi @brnrdog, here is some output from another Codex review run:
Findings
- High: Observers leak on initial compute/effect errors. If
compute()or the initial effect run throws, the observer stays inScheduler.observersand keeps any deps it already captured; there is no cleanup or rollback. This can leave stale deps and memory leaks.src/signals/Signals__Computed.res:23,src/signals/Signals__Computed.res:32,src/signals/Signals__Effects.res:23,src/signals/Signals__Effects.res:35. - Medium: Computeds propagate invalidations even when their derived value doesn’t change. The dirty flag triggers
notify(backingSignalId)before recompute, and recompute doesn’t check equality. This causes downstream effects to re-run even if the computed value is effectively unchanged, unlike many signal libs that short-circuit.src/signals/Signals__Scheduler.res:266,src/signals/Signals__Computed.res:14,src/signals/Signals__Signal.res:43. - Low: No ownership/auto‑disposal model; computed and effect observers persist until manually disposed. This is a common trade‑off but deviates from Solid/Vue patterns where effects are tied to scopes and auto‑cleaned on teardown.
src/signals/Signals__Computed.res:55,src/signals/Signals__Effects.res:52.
Comparison to common signal implementations
- Similarities: Uses a global “current observer” for dependency tracking and a dependency graph keyed by signal IDs, like SolidJS and Vue’s
effectsystem. Supportsbatchanduntrack, which mirror typical APIs. - Differences: Computeds are lazy (only recomputed on read via
ensureComputedFresh) and invalidations propagate immediately to dependents; Preact Signals and Solid memos typically use versioning/equality to avoid downstream work when values are unchanged. - Scheduling: Updates flush synchronously in the same call stack unless
batchis used. Many libraries (Preact Signals, Vue) queue microtasks to avoid deep synchronous cascades and improve interleaving. - Lifecycle: Manual disposal is required for both computeds and effects, while Solid/Vue usually provide ownership scopes and automatic teardown.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels