chore: always populate batch_values when updating a derived#17909
Open
Rich-Harris wants to merge 1 commit intomainfrom
Open
chore: always populate batch_values when updating a derived#17909Rich-Harris wants to merge 1 commit intomainfrom
Rich-Harris wants to merge 1 commit intomainfrom
Conversation
|
Contributor
|
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Never really understood this code if I'm honest. It was necessary at one point (it was introduced in #17105, and if you rewind the repo to that PR and remove the
ifguard, tests fail) but it doesn't seem to be doing anything now, possibly as a result of the scheduling refactor.And it's contributing to some undesirable behaviour — if we only populate
batch_valueswhen we're reading a derived while an effect is running, then we don't populatebatch_valueswhen we callupdate_derivedinsideis_dirty. In practice what this means is that we execute the derived once when we're checking to see if an effect that depends on it needs to re-run, and then again when we re-run the effect. That's silly!This PR doesn't fix that by itself. We additionally need
is_dirty(d)to returnfalseifbatch_values.has(d). But we can't do that yet, because in some circumstances it will lead to a derived incorrectly remainingDIRTY. Needs further investigation, either in this PR or a follow-up.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 testand lint the project withpnpm lint