skip adding dependencies for destroyed effects

aa-coordination
Rich Harris 7 months ago
parent c2869f5617
commit 5f2abc8fb4

@ -529,6 +529,7 @@ function remove_reaction(signal, dependency) {
} }
} }
} }
// If the derived has no reactions, then we can disconnect it from the graph, // If the derived has no reactions, then we can disconnect it from the graph,
// allowing it to either reconnect in the future, or be GC'd by the VM. // allowing it to either reconnect in the future, or be GC'd by the VM.
if ( if (
@ -965,6 +966,11 @@ export function get(signal) {
e.state_unsafe_local_read(); e.state_unsafe_local_read();
} }
// if we're in an async derived, the parent effect could have
// already been destroyed
var destroyed = active_effect !== null && (active_effect.f & DESTROYED) !== 0;
if (!destroyed) {
var deps = active_reaction.deps; var deps = active_reaction.deps;
if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) { if ((active_reaction.f & REACTION_IS_UPDATING) !== 0) {
@ -996,6 +1002,7 @@ export function get(signal) {
reactions.push(active_reaction); reactions.push(active_reaction);
} }
} }
}
} else if ( } else if (
is_derived && is_derived &&
/** @type {Derived} */ (signal).deps === null && /** @type {Derived} */ (signal).deps === null &&

Loading…
Cancel
Save