Skip to content

fix: make effectScope participate in propagation#111

Merged
johnsoncodehk merged 1 commit into
masterfrom
fix/issue-105-scope-propagation
May 10, 2026
Merged

fix: make effectScope participate in propagation#111
johnsoncodehk merged 1 commit into
masterfrom
fix/issue-105-scope-propagation

Conversation

@johnsoncodehk
Copy link
Copy Markdown
Collaborator

Summary

Fixes #105 — signals and computeds linked to different nodes when called in the same effectScope.

Root cause: Signals walked up the sub.subs?.sub chain to find a node with Mutable|Watching flags (the parent effect), bypassing inert scope nodes (flags=None). Computeds linked directly to activeSub (the scope). This inconsistency meant the parent effect could respond to signal changes but not computed changes through the scope.

Fix (3 changes):

  • Give effectScope the Mutable flag so it participates in dirty propagation
  • Remove the signal walk-up — both signal and computed now link to activeSub directly
  • Handle scope nodes in the update callback (clear flags, return true)

Test plan

  • Added 4 tests in tests/issue_105.spec.ts covering:
    • Signal and computed link to the same node in nested effectScopes
    • Effect responds to both signal and computed changes through scope
    • Scope responds to consecutive signal updates
    • Computed caching works in standalone scope
  • All 56 existing tests pass

Signals and computeds could link to different nodes when called in the
same effectScope. Signals walked up the sub chain to find a Mutable
node (the parent effect), while computeds linked directly to the inert
scope (flags=None). This meant the parent effect could not respond to
computed changes through the scope.

Fix by giving effectScope the Mutable flag so it participates in dirty
propagation, removing the signal walk-up (both signal and computed now
link to activeSub directly), and handling scope nodes in the update
callback.
@johnsoncodehk johnsoncodehk merged commit c28a596 into master May 10, 2026
2 checks passed
@johnsoncodehk johnsoncodehk deleted the fix/issue-105-scope-propagation branch May 10, 2026 21:34
littensy added a commit to littensy/reactivity that referenced this pull request May 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: Signals and computeds can link to different nodes when called in the same effect scope

1 participant