From d14efa3760023971b54d6f508cd0251ec1a7037b Mon Sep 17 00:00:00 2001 From: Ben Bucksch Date: Wed, 11 Jan 2023 18:42:06 +0100 Subject: [PATCH] Show helpful error message when calling writable() unsubscribe twice --- 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 e947fa0740..1b2481e572 100644 --- a/src/runtime/store/index.ts +++ b/src/runtime/store/index.ts @@ -99,6 +99,9 @@ export function writable(value?: T, start: StartStopNotifier = noop): Writ return () => { subscribers.delete(subscriber); if (subscribers.size === 0) { + if (stop === null) { + throw new Error('unsubscribe cannot be called twice'); + } stop(); stop = null; }