Skip to content

Commit

Permalink
ensure Stream.toReadableStream pulls always result in a enqueue (#3444)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Aug 12, 2024
1 parent 332b0c6 commit 04adcac
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/soft-cows-beam.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"effect": patch
---

ensure Stream.toReadableStream pulls always result in a enqueue
6 changes: 5 additions & 1 deletion packages/effect/src/internal/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6895,10 +6895,14 @@ export const toReadableStreamRuntime = dual<
return new ReadableStream<A>({
start(controller) {
scope = runSync(Scope.make())
pull = pipe(
const pullChunk: Effect.Effect<Chunk.Chunk<A>, Option.Option<E>, 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) => {
Expand Down

0 comments on commit 04adcac

Please sign in to comment.