8000 Throwing in a store subscriber nukes all stores, globally. · Issue #7618 · sveltejs/svelte · GitHub
[go: up one dir, main page]

Skip to content
Throwing in a store subscriber nukes all stores, globally. #7618
Closed as not planned
@cshaa

Description

@cshaa

Describe the bug

If a subscriber of any store from svelte/store throws an error, all stores immediately stop working – even if they're in an entirely different component.

This is because the subscriber_queue doesn't get cleared, but new subscribers are, for some bizarre reason, called only if the queue is empty.

Reproduction

For a detailed look, go to this REPL and follow instructions therein.

However the basic idea can be understood from the following code:

import { writable } from 'svelte/store';

let a = writable(1);
let b = writable(1);

a.subscribe(x => { if (x > 1) throw new Error(); });
try { a.set(42); } catch {}

b.set(2); // doesn't update

REPL

Logs

No response

System Info

Browsers:
    Brave Browser: 101.1.38.119
Packages:
    svelte: 3.48.0

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0