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; }