Commit fbabdbd
committed
fix: outer effect keeps responding to own dep after inner re-runs
When an inner effect re-runs on its own (its own dep changed),
notify() walks up the parent chain to add ancestors to the queue
and clears their Watching flag to prevent duplicate notification.
The parent then runs but isn't dirty/pending, so run() takes the
"not dirty" branch.
Before #109/#110, that branch unconditionally restored Watching.
The fix in #109/#110 added `if (e.flags)` to avoid restoring
Watching on disposed effects (whose flags were zeroed during
checkDirty's traversal). Unfortunately, parents added to the
queue via the chain also have flags === 0 (notify just cleared
Watching, no other flag set), so they fell into the same branch
and lost Watching permanently — the outer effect stopped
responding to its own dep after any inner re-run.
Disposed effects also have deps === undefined (purgeDeps clears
them). Use that as the more precise discriminator: restore
Watching when the effect still has deps, skip when fully disposed.
Fixes #115. Added a regression test mirroring the report.1 parent 0775f82 commit fbabdbd
2 files changed
Lines changed: 27 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
269 | 269 | | |
270 | 270 | | |
271 | 271 | | |
272 | | - | |
| 272 | + | |
273 | 273 | | |
274 | 274 | | |
275 | 275 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
0 commit comments