From a83c336ffb57fef9e8712ffa15620f0cd54cd2a7 Mon Sep 17 00:00:00 2001 From: Simon H <5968653+dummdidumm@users.noreply.github.com> Date: Tue, 14 Mar 2023 10:34:33 +0100 Subject: [PATCH] Update src/runtime/store/index.ts --- src/runtime/store/index.ts | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/runtime/store/index.ts b/src/runtime/store/index.ts index 76b2a61503..67c2bcb15c 100644 --- a/src/runtime/store/index.ts +++ b/src/runtime/store/index.ts @@ -203,6 +203,9 @@ export function derived(stores: Stores, fn: Function, initial_value?: T): Rea return function stop() { run_all(unsubscribers); cleanup(); + // We need to set this to false because callbacks can still happen despite having unsubscribed: + // Callbacks might already be placed in the queue which doesn't know it should no longer + // invoke this derived store. started = false; }; });