Skip to content

fix: effect teardown on failed setup, computed throw recovery - #126

Open
nickchomey wants to merge 6 commits into
stackblitz:masterfrom
nickchomey:bug-fixes
Open

fix: effect teardown on failed setup, computed throw recovery#126
nickchomey wants to merge 6 commits into
stackblitz:masterfrom
nickchomey:bug-fixes

Conversation

@nickchomey

@nickchomey nickchomey commented Sep 2, 2026

Copy link
Copy Markdown

This PR fixes a few related bugs. It comes in 3 pairs of red tests/green fix commits.

Note that this Supersedes/rebases #119, which fixes #118. I didnt create an issue for the two new bugs i found and fixed

Bug 1 - effect / effectScope leave live subscriptions after failed setup

Tests:

  • Stopped effect stays stopped. Reads signal, stops mid-run, reads another signal. Ends with no deps, never re-runs.
  • Failed effect setup cleaned up. Reads signal then throws. Throw propagates. Later writes do not re-run.
  • Failed scope setup cleans up children. Creates child effect then throws. Throw propagates. Later writes do not re-run child.

Fix:

  • Failed setup leaves nothing behind.
  • Inactive subscribers ignore later reads in same run.

Bug 2 - computed throwing on first evaluation never recovers

Tests:

  • Throwing computed recovers. Throws while dependency is 0, read inside catching effect. After dependency becomes 5, effect re-runs and reads 10.

Fix:

  • Failed evaluation still subscribes.
  • Dependency change triggers re-evaluation.

Bug 3 - throwing computed returns stale undefined instead of re-throwing

Tests:

  • Unrelated re-run still throws. Subscriber also reads unrelated signal. Write to unrelated signal re-runs subscriber without changing computed deps. Same error observed, getter not re-invoked.
  • Direct re-read still throws. Two consecutive reads throw with single getter call. After dep change, correct value returned.

Fix:

  • Failed evaluation is retained.
  • Unchanged dependencies re-throw, changed dependencies re-evaluate.

@bolt-new-by-stackblitz

Copy link
Copy Markdown

Review PR in StackBlitz Codeflow Run & review this pull request in StackBlitz Codeflow.

@nickchomey nickchomey changed the title Bug fixes fix: effect teardown on failed setup, computed throw recovery Sep 2, 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.

Stopped effects can be re-subscribed and failed effect/effectScope setup can leak nodes

1 participant