Skip to content

toStore not receiving updates from 5.22.3 onwards #15557

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

Closed
jamesbirtles opened this issue Mar 20, 2025 · 1 comment · Fixed by #15574
Closed

toStore not receiving updates from 5.22.3 onwards #15557

jamesbirtles opened this issue Mar 20, 2025 · 1 comment · Fixed by #15574
Assignees

Comments

@jamesbirtles
Copy link
Contributor

Describe the bug

From 5.22.3 onwards, usage of toStore seems broken.

A simple case of wrapping some state

const count = toStore(() => counter, value => counter = value);

and then using it in the template for example

Count state: {counter}
Count store: {$count}

The count state updates as expected, but the count store never receives a new value.

Reproduction

See the following basic example:
https://svelte.dev/playground/0892822945674a63ad0d61aca0eba214?version=5.22.3

It works when running on 5.22.2:
https://svelte.dev/playground/0892822945674a63ad0d61aca0eba214?version=5.22.2

It also starts to work if you $inspect the store
https://svelte.dev/playground/a1380d57e6c24ab3aff00d8b74cda745?version=5.22.3

Logs

System Info

System:
    OS: Linux 6.11 cpe:/o:nixos:nixos:25.05 25.05 (Warbler)
    CPU: (16) x64 AMD Ryzen 7 7840U w/ Radeon  780M Graphics
    Memory: 41.81 GB / 60.64 GB
    Container: Yes
    Shell: 5.9 - /run/current-system/sw/bin/zsh
  Binaries:
    Node: 22.14.0 - /etc/profiles/per-user/james/bin/node
    Yarn: 1.22.22 - /etc/profiles/per-user/james/bin/yarn
    npm: 10.9.2 - /etc/profiles/per-user/james/bin/npm
  Browsers:
    Chromium: 134.0.6998.88
  npmPackages:
    svelte: ^5.23.2 => 5.23.

Severity

blocking an upgrade

@trueadm
Copy link
Contributor

trueadm commented Mar 21, 2025

This is due to #15446. The reason this is happening is because we're now associating the root effect created in toStore to the template effect – as that is what is calling the read on the toStore. When the template effect gets invalidated, it now destroys the root effect each time – killing the store contract entirely.

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

Successfully merging a pull request may close this issue.

2 participants