SIGN IN SIGN UP
sveltejs / svelte UNCLAIMED

web development for the rest of us

0 0 70 JavaScript

fix: `{#await await ...}` and async dependencies fixes (#18243)

This started out as an investigation to get rid of the runtime code for
`{#await ...}` that deactivated a batch prior to reading the promise
function. That can result in a new batch being created if the promise
invocation happens to write a source.

Through that I discovered two other bugs:
1. The way we handle `{#await await ...}` was flawed around
SSR/hydration: On the server it would await the expression (which it
should not; `{#await await ...}` is kind of a weird special case here)
and during hydration it did not produce matching nodes, leading to
hydration fails.
2. When reading a dependency after an await expression which we add to
the current reaction, we did not deduplicate those reads. That can lead
to duplicate dependencies, which in turn can lead to bugs when
`remove_reaction` later runs. Conside this: You have `deps = [count,
unrelated, count]`. Now you do `remove_reactions(deps, 1)`, i.e. "remove
all reactions after the first one". That means the "disconnect these
from each other" logic runs for `count`, too, because it's also in the
third position, but that is wrong because it is also in the first
position, i.e. the connection should be kept.

---------

Co-authored-by: Rich Harris <rich.harris@vercel.com>
S
Simon H committed
000c594e05d27e3e56c08cf30274689615d99092
Parent: be8ffeb
Committed by GitHub <noreply@github.com> on 5/19/2026, 8:16:03 PM