Skip to content
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: increment derived versions when updating #12047

Merged
merged 4 commits into from
Jun 17, 2024
Merged

fix: increment derived versions when updating #12047

merged 4 commits into from
Jun 17, 2024

Conversation

Rich-Harris
Copy link
Member

@Rich-Harris Rich-Harris commented Jun 16, 2024

This is an alternative to #12016 that I think is slightly simpler. AFAICT all we need to do is ensure that if a derived a depends on another derived b, and a is reconnecting to the dependency graph, that if b was updated more recently than a, a also updates.

Fixes #11988
Fixes #12044

Before submitting the PR, please make sure you do the following

  • It's really useful if your PR references an issue where it is discussed ahead of time. In many cases, features are absent for a reason. For large changes, please create an RFC: https://github.com/sveltejs/rfcs
  • Prefix your PR title with feat:, fix:, chore:, or docs:.
  • This message body should clearly illustrate what problems it solves.
  • Ideally, include a test that fails without this PR but passes with it.

Tests and linting

  • Run the tests with pnpm test and lint the project with pnpm lint

Copy link

changeset-bot bot commented Jun 16, 2024

🦋 Changeset detected

Latest commit: 2a9da58

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
svelte Patch

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

@@ -257,9 +264,10 @@ export function check_dirtiness(reaction) {
// In thise case, we need to re-attach it to the graph and mark it dirty if any of its dependencies have
// changed since.
if (version > /** @type {import('#client').Derived} */ (reaction).version) {
/** @type {import('#client').Derived} */ (reaction).version = version;
/** @type {import('#client').Derived} */ (reaction).version = increment_version();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are you incrementing here? You should be matching the value otherwise you might cause additional invalidations that aren’t necessary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't think it would cause unnecessary invalidations. but yeah, we actually only need to increment in two places — in set and update_derived

@FoHoOV
Copy link
Contributor

FoHoOV commented Jun 17, 2024

Hey! this or #12016 also fixes #12044.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants