Skip to content

Svelte stores become stuck after unhandled exception in subscriber #11555

@nhhollander

Description

@nhhollander

Describe the bug

If any svelte store subscriber raises an un-handled exception, future calls to .set() on any store will not notify subscribers.

In file svelte/src/store/index.js:58 in function set():

At line 58 the run_queue flag is set to true if there are no pending entries in the subscription queue1. After the queue has finished running, the queue is emptied by calling subscriber_queue.length = 0 at line 67. In the event that an un-handled exception is raised from one of the subscribers, the function exits without clearing subscriber_queue. These dangling items cause the check on line 58 to always return false, preventing the dispatch loop from running until the page is reloaded.

Reproduction

https://svelte.dev/repl/7521a9a8fc53451bbc1b229eb50dd587?version=4.2.16

Logs

No response

System Info

System:
  OS: Linux 6.8 Arch Linux
  CPU: (24) x64 AMD Ryzen 9 3900X 12-Core Processor
  Memory: 12.92 GB / 62.74 GB
  Container: Yes
  Shell: 5.9 - /bin/zsh
Binaries:
  Node: 21.7.1 - /usr/bin/node
  npm: 10.4.0 - ~/.npm/bin/npm
npmPackages:
  svelte: ^4.0.5 => 4.2.16

Severity

annoyance

Footnotes

  1. This behavior was first introduced in 46c9dbe4.

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