diff --git a/.changeset/soft-cows-beam.md b/.changeset/soft-cows-beam.md new file mode 100644 index 0000000000..a478d224ba --- /dev/null +++ b/.changeset/soft-cows-beam.md @@ -0,0 +1,5 @@ +--- +"effect": patch +--- + +ensure Stream.toReadableStream pulls always result in a enqueue diff --git a/packages/effect/src/internal/stream.ts b/packages/effect/src/internal/stream.ts index 9d28dab7f9..459827d6bc 100644 --- a/packages/effect/src/internal/stream.ts +++ b/packages/effect/src/internal/stream.ts @@ -6895,10 +6895,14 @@ export const toReadableStreamRuntime = dual< return new ReadableStream({ start(controller) { scope = runSync(Scope.make()) - pull = pipe( + const pullChunk: Effect.Effect, Option.Option, R> = pipe( toPull(self), Scope.extend(scope), runSync, + Effect.flatMap((chunk) => Chunk.isEmpty(chunk) ? pullChunk : Effect.succeed(chunk)) + ) + pull = pipe( + pullChunk, Effect.tap((chunk) => Effect.sync(() => { Chunk.map(chunk, (a) => {