Skip to content

Stores cannot be used in async components #16440

@ottomated

Description

@ottomated

Describe the bug

If any stores are used in an async component, the $$cleanup function gets injected in a different function than it's called.

<script>
  import {writable} from 'svelte/store';
  const store = writable('world');
  await 'anything';
</script>

<h1>Hello {$store}!</h1>

$setup_stores gets called inside the async $body function, but $$cleanup goes in the actual component body.

Reproduction

reproduction

Logs

$$cleanup is not defined in <unknown> in __wrapper.svelte

System Info

svelte 5.36.8 in playground

Severity

blocking an upgrade

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    pFad - Phonifier reborn

    Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

    Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy