From b858e05c1b8cfb02ba5beb5fbe90ec81e86715a1 Mon Sep 17 00:00:00 2001 From: Tim Date: Thu, 18 Jul 2024 13:24:15 +1200 Subject: [PATCH] default to unbounded buffer --- .changeset/beige-rules-argue.md | 6 ------ .changeset/forty-beers-refuse.md | 6 +++--- packages/effect/src/Stream.ts | 6 +++--- packages/effect/src/internal/stream.ts | 6 +++--- 4 files changed, 9 insertions(+), 15 deletions(-) delete mode 100644 .changeset/beige-rules-argue.md diff --git a/.changeset/beige-rules-argue.md b/.changeset/beige-rules-argue.md deleted file mode 100644 index 8b2c0671f1f..00000000000 --- a/.changeset/beige-rules-argue.md +++ /dev/null @@ -1,6 +0,0 @@ ---- -"effect": patch -"@effect/platform-browser": patch ---- - -use "unbounded" buffer for Stream.fromEventListener diff --git a/.changeset/forty-beers-refuse.md b/.changeset/forty-beers-refuse.md index 6f862903e49..17c20ae72c5 100644 --- a/.changeset/forty-beers-refuse.md +++ b/.changeset/forty-beers-refuse.md @@ -10,9 +10,9 @@ You can use the `emit` helper to emit values to the stream. You can also use the `emit` helper to signal the end of the stream by using apis such as `emit.end` or `emit.fail`. -By default it uses a buffer size of 4096 and a dropping strategy to prevent -memory issues. You can customize the buffer size and strategy by passing an -object as the second argument with the `bufferSize` and `strategy` fields. +By default it uses an "unbounded" buffer size. +You can customize the buffer size and strategy by passing an object as the +second argument with the `bufferSize` and `strategy` fields. ```ts import { Effect, Stream } from "effect"; diff --git a/packages/effect/src/Stream.ts b/packages/effect/src/Stream.ts index 54ae94cdc59..e57c2d52af6 100644 --- a/packages/effect/src/Stream.ts +++ b/packages/effect/src/Stream.ts @@ -382,9 +382,9 @@ export const asyncEffect: ( * You can also use the `emit` helper to signal the end of the stream by * using apis such as `emit.end` or `emit.fail`. * - * By default it uses a buffer size of 4096 and a dropping strategy to prevent - * memory issues. You can customize the buffer size and strategy by passing an - * object as the second argument with the `bufferSize` and `strategy` fields. + * By default it uses an "unbounded" buffer size. + * You can customize the buffer size and strategy by passing an object as the + * second argument with the `bufferSize` and `strategy` fields. * * @example * import { Effect, Stream } from "effect" diff --git a/packages/effect/src/internal/stream.ts b/packages/effect/src/internal/stream.ts index e01476b16b4..43653502fe4 100644 --- a/packages/effect/src/internal/stream.ts +++ b/packages/effect/src/internal/stream.ts @@ -603,14 +603,14 @@ const queueFromBufferOptionsPush = ( readonly strategy?: "dropping" | "sliding" | undefined } | undefined ): Effect.Effect> => { - if (options?.bufferSize === "unbounded") { + if (options?.bufferSize === "unbounded" || (options?.bufferSize === undefined && options?.strategy === undefined)) { return Queue.unbounded() } switch (options?.strategy) { case "sliding": - return Queue.sliding(options?.bufferSize ?? DefaultChunkSize) + return Queue.sliding(options.bufferSize ?? 16) default: - return Queue.dropping(options?.bufferSize ?? DefaultChunkSize) + return Queue.dropping(options?.bufferSize ?? 16) } }