Empty Stream Yield Error
Trace a yielded Stream that completes before emitting its first value.What this error means and what can trigger it
EmptyStreamYieldError means SER converted a Stream from Effect used in a value-style yield*, ran it for its head, and observed normal completion before any element was emitted.
The empty case is narrower than it may first appear. A Stream that fails before emitting keeps its original error, while one that neither emits nor completes remains pending. Even undefined counts as an emitted value because Option.some(undefined) is still present. Once the first element arrives, this conversion consumes nothing further.
Exactly where it triggers
return Stream.runHead(yieldable).pipe(
Effect.flatMap((head) => {
if (Option.isSome(head)) {
return Effect.succeed(head.value);
}
return Effect.fail(new EmptyStreamYieldError());
}),
);SER reports this through Effect.fail, rather than a JavaScript throw, so an empty completion enters the generated component effect's typed failure channel.
For reference, the class itself is declared at modules/svelte-effect-runtime/src/errors.ts L522 @ C14.
Why this is the case
A value expression must resume with one concrete value. Streams in Effect may contain zero elements, so converting a Stream to a single value requires an explicit empty case.
SER uses Stream.runHead because value-style yielding asks for the first resolved value rather than continuous subscription or full consumption. Normal empty completion cannot manufacture a value of the Stream's element type, so the conversion adds EmptyStreamYieldError to that overload's failure type.