mirror of https://github.com/sveltejs/svelte
fix: prevent derived connection leak in untracked contexts (#18501)
When a is only read inside an untracked context such as (()), is_updating_effect was causing should_connect to return true even though the active reaction (b) is not connected. This caused derived (a) to be spuriously marked CONNECTED and added to its dependencies' reactions arrays. When the component is destroyed, nothing removes these stale deriveds from their deps' reactions, creating a memory leak that retains the entire component scope. Removing is_updating_effect from the should_connect condition ensures that a derived is only connected when read by a reaction that is actually part of the reactive graph. A disconnected derived reading another derived should not cause the inner derived to connect.pull/18517/head
parent
8fb7ceeba5
commit
d9a5cc1802
Loading…
Reference in new issue