Skip to content

The latest value, instead of the previous value, is provided in $effect teardown if the state is a $derived #16114

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

Open
OptimisticSean opened this issue Jun 9, 2025 · 1 comment
Labels
bug p0 stuff we should fix ASAP
Milestone

Comments

@OptimisticSean
Copy link

Describe the bug

Not sure if this is a bug or intended. According to this breaking change, if the state caused an $effect to rerun, Svelte should provide the previous value of the state in the teardown function. This work for $state currently, but not for $derived, though it does work if $derived is reassigned.

Reproduction

https://svelte.dev/playground/untitled?version=5.33.18#H4sIAAAAAAAACnWPy2rEMAxFf8WIgcl0woSuCm4SmC_oqqumizyU1tRVjKVkOgT_e3HS92MldHSPZM9A9TOChlsSIxY7SKE3Fhn03QxydnEWAaTvyaNzB57QSmRNzfgXbwcSJGHQkHPrjZOyokosimJVqA1LLZhc7q4_6II79GbCLuELXkZUyQb7HltJkp0qSjVHVEk7EA8WD3Z4SLaPRjFrtU0Vr5ZU4lFGT-qb9ENrzvjbC7GEXUV59vlsyptRZCA1UGtN-1TM617e70N57DrFebYmyv-z8X9XobyZ0J-8kXj7q-VK1mrmkGfurV36FUAKgi8CWvyI4T4FqY09GepA97VlDK_x94v_xwEAAA==

Logs

System Info

Svelte playground (5.33.18)
Chrome 137.0.7151.56

Severity

annoyance

@rChaoz
Copy link
Contributor

rChaoz commented Jun 11, 2025

Strongly related to #16019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug p0 stuff we should fix ASAP
Projects
None yet
Development

No branches or pull requests

3 participants