LearnNewsExamplesConnect
Frontmatter
assigneestobiu
createdAtJul 13, 2025, 1:57 PM
updatedAtJul 13, 2025, 1:58 PM
githubUrlhttps://github.com/neomjs/neo/issues/7042
authortobiu
commentsCount0
parentIssue6992
subIssues[]
subIssuesCompleted0
subIssuesTotal0
contentTrust
projected
quarantined0
signals[]
blockedBy[]
blocking[]
closedAtJul 13, 2025, 1:58 PM

Regression: Neo.core.Effect.run() executes twice

tobiu
tobiu commented on Jul 13, 2025, 1:57 PM

Describe the bug The Neo.core.Effect.run() method was executing an additional, unintended time, leading to incorrect behavior in reactive bindings. This was observed in tests where effects were expected to run only once initially, but were running twice.

To Reproduce Steps to reproduce the behavior:

  1. Run the test suite tests/state/Provider.mjs.
  2. Observe failed assertions related to effectRunCount, such as:
    • Binding effect should run once initially (Expected: 1, Got: 2)
    • Binding effect should re-run after setData (Expected: 2, Got: 4)
    • Similar failures in hierarchical data access tests.

Expected behavior The Neo.core.Effect.run() method should execute only once per intended trigger. The effectRunCount in the tests/state/Provider.mjs should match the expected values (e.g., 1 for initial run, 2 after first setData, etc.).

Additional context This regression was introduced when the isRunning property of Neo.core.Effect was changed to a Neo.core.Config instance. The Effect was inadvertently subscribing to its own isRunning changes during its execution, creating a circular dependency that caused run() to be invoked recursively.

The fix involved strategically pausing and resuming EffectManager's dependency tracking within the Effect.run() method to prevent the Effect from registering itself as a dependency of its own isRunning config during its execution, and to prevent recursive calls when isRunning was set.