Skip to content

$effect does not run after async derived completes, but after the next wakeup #16497

@RuthgerD

Description

@RuthgerD

Describe the bug

the following code does not work:

const foo = $derived(await a());

$effect(() => {
  console.log("hello", foo)
})

however if you mutate an unrelated $state variable the effect is suddenly run, indicating that this is an unintentional bug.

see reproduction for a full example, press the "wake" button to observe this behaviour.

Reproduction

https://svelte.dev/playground/267ec9aa67c248d8b2d65aaffd1f02f8?version=5.36.16

Severity

annoyance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions