-
-
Notifications
You must be signed in to change notification settings - Fork 4.6k
fix: ensure unowned deriveds can add themselves as reactions while connected #16249
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Conversation
🦋 Changeset detectedLatest commit: 065690b 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 |
|
@@ -112,6 +112,45 @@ describe('signals', () => { | |||
}; | |||
}); | |||
|
|||
test('unowned deriveds are not added as reactions but trigger effects', () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the name of the test correct? Isn't the change that we actually add the derived as a reaction? I think it makes sense: the problem is probably that we check if the derived is UNOWNED
before executing it so if the execution changes that (connecting it) when we reach the point of the code you changes skip_reaction
should be false (because now the derived it's not unowned anymore) but it's still true and you can check that by looking if it has reactions (or i suppose we could also check if (reaction.f & UNOWNED) !== 0
in line?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw scratch the last sentence, I confused it and also the flag is never set to false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to spend the whole day to figure out if there was a different way we could get the hint that "this unowned derived can be cleared so add it anyway" and i couldn't...but I think the important bit is that it works and doesn't leak reactions...so i would say let's go with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to spend the whole day to figure out if there was a different way we could get the hint that "this unowned derived can be cleared so add it anyway" and i couldn't...but I think the important bit is that it works and doesn't leak reactions...so i would say let's go with it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried to spend the whole day to figure out if there was a different way we could get the hint that "this unowned derived can be cleared so add it anyway" and i couldn't...but I think the important bit is that it works and doesn't leak reactions...so i would say let's go with it?
Fixes #15829 and potentially #15853
I can't quite articulate yet why this is right, but I think it is. Basically, an unowned derived should still add itself as a reaction while it is properly connected, which means it can be cleaned up correctly - and this connection is indicated by it having reactions.
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint