Will It Vibe logoWill It Vibe?
SVELTE-005Medium severity-8 points

Store subscription is discarded (never unsubscribed)

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 8 points from that category, once per scan, no matter how many places it turns up.

What it detects

Calling store.subscribe() as a bare statement throws away the returned unsubscribe function, so the subscription lives past the component and leaks memory and stale updates. Prefer the $store auto-subscription, or keep the unsubscribe and call it in onDestroy.

Why it matters

store.subscribe() returns an unsubscribe function. Calling it as a bare statement and discarding that return value means the subscription is never torn down, so it keeps running after the component is destroyed, holds the component in memory, and can fire callbacks against unmounted state. In a page that mounts and unmounts components this leaks steadily.

How to fix it

Prefer Svelte auto-subscription: reference the store as $store in markup and script and Svelte subscribes and unsubscribes for you. If you need a manual subscription, capture the returned function and call it in onDestroy, for example const unsub = store.subscribe(fn); onDestroy(unsub). The onMount callback can also return the unsubscribe function directly.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks