-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: ensure reactions are correctly attached for unowned deriveds #15158
Conversation
🦋 Changeset detectedLatest commit: f04f22b The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
could you explain what deriveds were unowned in this example? Looking at the generated code, shouldn't it be seen as owned (directly created in an effect; the root effect)? |
Deriveds are no longer attached to effect. Effects and deriveds no longer own deriveds too – this was changed in a previous PR because it was leading to bugs where the derived was being destroyed when the effect or owning derived re-runs. If you create a derived in something like a class and then pass that out of the owning derived or effect then it makes no sense for it suddenly get destroyed by something else. Deriveds are marked as unowned when they're read outside of a tracked context – in this case from the |
Ok, so asking differently - in which cases are deriveds still owned? Because it sounds like they are almost never owned now? |
@dummdidumm A derived being unowned doesn't mean it still can't be connected to the graph – they are mostly connected to the graph when a tracking effect references them. If a derived is only ever read inside an effect, it is never set as unowned too. |
Fixes #15149. We weren't setting the
active_reaction
when processing effects and checking if they were dirty, which mean theskip_reaction
logic was not treating unowned deriveds as connected even though they should as we're flushing effects at this stage of reconciliation.