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

#16114

Development PRs

Issue

Solved
S
SeanIsTyping
Jun 9, 2025, 12:54 PM

Describe the bug

Not sure if this is a bug or intended. According to , 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

Logs

System Info

Svelte playground (5.33.18)
Chrome 137.0.7151.56

Severity

annoyance

Info

Closed at Jul 7, 2025, 5:32 PM
Assignees None
Labels bug, p0
Milestone 5.x