Describe the problem
1
An exception is that independent $derived expressions will update independently, even though they will run sequentially when they are first created:
// these will run sequentially the first time,
// but will update independently
let a = $derived(await one());
let b = $derived(await two());
1-1
'run sequentially' is confusing.
For example, the promises can be created sequentially, but b can resolve first. The truth is:
...the second $derived will not be created until the first one has resolved.
Why not be specific like the quote in await_waterfall docs?
Clarification is needed because $derived isn't vanilla JavaScript.
// this is intuitive. `two` is called after `one` is resolved.
await one();
await two();
// this is not intuitive
$derived(await one());
$derived(await two());
1-2
'update independently' is confusing.
Can one and two rerun? They don't have any dependencies.
$derived(await one());
$derived(await two());
Example from query remote function seems better:
let a = $derived(await one());
const post = $derived(await getPost(params.slug)); // params.slug is the dependency
2
Anything read synchronously inside the $derived expression (or $derived.by function body) is considered a dependency of the derived state.
Claude is complaining that params.slug is not read synchronously, thus not a dependency.
$derived(await getPost(params.slug));
What are considered dependencies in async Svelte and $derived?
Note
I believe I've used await inside $derived.by as an alternative to untrack. Maybe this should be warned on Svelte 5 to 6 migration? I didn't see it in the breaking changes section.
Describe the proposed solution
See above
Importance
nice to have