Skip to content

Multiple await someFunction() in a derived results in unsafe_state_mutation error #17361

@kevmodrome

Description

@kevmodrome

Describe the bug

When you have two awaits in a $derived you will get a unssafe_state_mutation error even though no state is being updated:

let postsAndComments = $derived({
	posts: await posts(),
	comments: await comments()
})

Reproduction

https://www.sveltelab.dev/ds3d9yw8emutk33

Logs

Uncaught (in promise) Svelte error: state_unsafe_mutation
	Updating state inside `$derived(...)`, `$inspect(...)` or a template expression is forbidden. If the value should not be reactive, declare it without `$state`
	https://svelte.dev/e/state_unsafe_mutation

System Info

System:
    OS: macOS 26.1
    CPU: (16) arm64 Apple M4 Max
    Memory: 42.27 GB / 128.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 22.12.0 - /Users/kevin/.volta/tools/image/node/22.12.0/bin/node
    npm: 10.9.0 - /Users/kevin/.volta/tools/image/node/22.12.0/bin/npm
    pnpm: 10.4.1 - /Users/kevin/.volta/bin/pnpm
    bun: 1.3.4 - /Users/kevin/.bun/bin/bun
    Deno: 2.5.6 - /opt/homebrew/bin/deno
  Browsers:
    Chrome: 143.0.7499.41
    Safari: 26.1
    Safari Technology Preview: 26.0
  npmPackages:
    svelte: ^5.46.0 => 5.46.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