Skip to content

await_waterfall suggested fix does not work due to lazy evaluation #16483

@RuthgerD

Description

@RuthgerD

Describe the bug

According to:
https://svelte.dev/docs/svelte/runtime-warnings#Client-warnings-await_waterfall

You can start concurrent promises by creating them prior to awaiting them, on paper this seems fine however $derived values are lazy meaning it can't really work conceptually:

let aPromise = $derived(one());
let bPromise = $derived(two());

// at this point one() and two() have not been called yet

let a = $derived(await aPromise); // aPromise is evaluated, one() is called (async derived is eager)
let b = $derived(await bPromise); // bPromise is only evaluated once `a` is done

forcing evaluation of the derived values "fixes this" (e.g $inspect(aPromise, bPromise)), but that is a bit dumb.

What is the expected behavior here?

Reproduction

https://svelte.dev/playground/d3a249ca4fd44e24b6f83e66375cbc22?version=5.36.13

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