Await In Effect Work Error
Trace one lowered statement that mixes native await with effect sequencing.What this error means and what can trigger it
AwaitInEffectWorkError means one script statement belongs to both JavaScript's Promise continuation model and SER's effect generator model. The statement contains a top-level yield*, SER successfully lowered at least one effect block from it, and the same statement also contains a top-level await.
Here, top-level is relative to the statement SER is inspecting; the detectors do not descend through nested function boundaries. An ordinary statement such as const response = await fetch(url) is left alone because it contains no SER work, whereas record(await transform(yield* Load())) mixes both execution models in one expression and is rejected.
Exactly where it triggers
const has_top_level_yield_star = contains_top_level_yield_star(stmt);
if (!has_top_level_yield_star) {
continue;
}
has_effect = true;
const lowered = lower_statement(stmt, content, context);
if (lowered.effect_blocks.length > 0 && contains_top_level_await(stmt)) {
const text = slice(content, stmt);
throw new AwaitInEffectWorkError(filename, text);
}All three predicates are relevant: a top-level yield* must exist, lowering must have produced an effect block, and a top-level await must remain in that statement. The exception is synchronous and stops preprocessing.
For reference, the class itself is declared at modules/svelte-effect-runtime/src/errors.ts L126 @ C14.
Why this is the case
The lowered statement runs inside generator-based effect sequencing, where yield* controls suspension, interruption, scope, and the typed error channel. Native await suspends an async JavaScript function around a Promise. SER would have to invent how Promise cancellation, rejection, and continuation order interact with the dispatcher-owned effect fiber.
By rejecting the mixed statement, SER keeps the two execution models explicit. Ordinary Svelte top-level await remains untouched in statements that SER does not lower.