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

Derived stores with multiple dependencies don't always update. #3191

Closed
pngwn opened this issue Jul 6, 2019 · 5 comments · Fixed by #3219
Closed

Derived stores with multiple dependencies don't always update. #3191

pngwn opened this issue Jul 6, 2019 · 5 comments · Fixed by #3219
Labels

Comments

@pngwn
Copy link
Member

pngwn commented Jul 6, 2019

When a store has multiple dependencies it won't always update when those dependencies update. This is only present when one of the dependencies is derived from the other dependency (I think).

REPL

Thanks to @Conduitry's detective work, it seems like this bug was possibly introduced by #2955.

@Conduitry Conduitry added the bug label Jul 6, 2019
@mrkishi
Copy link
Member

mrkishi commented Jul 7, 2019

The issue here is that deriveds are always invalidated:

() => {
run_all(invalidators);
pending |= (1 << i);
}),

But not necessarily updated:

if (safe_not_equal(value, new_value)) {
value = new_value;
if (!stop) {
return; // not ready
}
subscribers.forEach((s) => s[1]());
subscribers.forEach((s) => s[0](value));
}

pending needs to be reset even if !safe_not_equal().

@btakita
Copy link
Contributor

btakita commented Jul 10, 2019

One of my apps (>1000 stores) is dead in the water until this is fixed. Any thoughts on what can be done?

@btakita
Copy link
Contributor

btakita commented Jul 10, 2019

To get around this issue, one can use a writable & manually set it's value using subscribe.

https://svelte.dev/repl/14d838206c5c4114b16ce51a4bb3ec71?version=3.6.7

btakita added a commit to btakita/svelte that referenced this issue Jul 11, 2019
Derived store reruns subscribers if it's value has not changed when synced.

All invalidators of subscribers are run on a derived store when invalidated.

See sveltejs#2955
btakita added a commit to btakita/svelte that referenced this issue Jul 11, 2019
btakita added a commit to btakita/svelte that referenced this issue Jul 11, 2019
btakita added a commit to btakita/svelte that referenced this issue Jul 11, 2019
@btakita
Copy link
Contributor

btakita commented Jul 11, 2019

I have a hotfix for v3.6.7 at:

"svelte": "btakita/svelte#gh-3191-hotfix"

btakita added a commit to btakita/svelte that referenced this issue Jul 23, 2019
Derived store reruns subscribers if it's value has not changed when synced.

All invalidators of subscribers are run on a derived store when invalidated.

See sveltejs#2955
@btakita
Copy link
Contributor

btakita commented Jul 24, 2019

v3.6.8 hotfix "svelte": "btakita/svelte#3.6.8-gh-3191-hotfix"

@Rich-Harris What are your thoughts on #3219? Thank you

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

Successfully merging a pull request may close this issue.

4 participants