Skip to content

More Codex feedback #6

@cknitt

Description

@cknitt

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 in Scheduler.observers and 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 effect system. Supports batch and untrack, 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 batch is 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions