-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Description
Describe the bug
When a child $effect is conditionally called by a $derived, the effect cleanup is deferred until right before the effect is called again or the component is destroyed. See the linked reproduction for a simple example. Notice how the effect cleanup isn't run until right before the getValue function is called again; try toggling the checkbox.
Since the getValue function effectively becomes unused by the component when the condition becomes false, it seems like the effect should be destroyed. If the effect were being used to track a subscription, for example, this could be problematic because there'd be no immediate signal when the component had lost interest in the results of getValue.
I'm not sure if this is a bug or expected behavior, so apologies for the noise if this is working as expected.
Reproduction
Logs
No response
System Info
Svelte 5.0.0-next.269Severity
annoyance