Skip to content

Commit 8055046

Browse files
committed
dont reconnect deriveds inside destroyed effects
1 parent b64cfc6 commit 8055046

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

packages/svelte/src/internal/client/runtime.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,12 @@ export function check_dirtiness(reaction) {
204204
var length = dependencies.length;
205205

206206
// If we are working with a disconnected or an unowned signal that is now connected (due to an active effect)
207-
// then we need to re-connect the reaction to the dependency
208-
if (is_disconnected || is_unowned_connected) {
207+
// then we need to re-connect the reaction to the dependency, unless the effect has already been destroyed
208+
// (which can happen if the derived is read by an async derived)
209+
if (
210+
(is_disconnected || is_unowned_connected) &&
211+
(active_effect === null || (active_effect.f & DESTROYED) === 0)
212+
) {
209213
for (i = 0; i < length; i++) {
210214
dependency = dependencies[i];
211215

0 commit comments

Comments
 (0)