From cb8f18309459783af8f977b8ba08318fffde459c Mon Sep 17 00:00:00 2001 From: Brian Jenkins Date: Thu, 26 Mar 2026 11:37:42 -0400 Subject: [PATCH] Allow passing buffer size options to channel() The `SharedJsonBuffer` constructor already accepts a `{ size }` option, but `channel()` doesn't expose it. This makes it impossible to send large messages through a channel without hitting the default 64KB limit. Thread the options bag through so callers can do: const [tx, rx] = channel(32, { size: 1024 * 1024 * 5 }); --- src/lib/sync/mpmc.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib/sync/mpmc.ts b/src/lib/sync/mpmc.ts index 62ae536..302d010 100644 --- a/src/lib/sync/mpmc.ts +++ b/src/lib/sync/mpmc.ts @@ -362,7 +362,7 @@ export class Receiver extends ChannelHandle { } } -export function channel(capacity: number = 32): [Sender, Receiver] { +export function channel(capacity: number = 32, options?: { size?: number }): [Sender, Receiver] { const state = new Int32Array( new SharedArrayBuffer(META_SIZE * Int32Array.BYTES_PER_ELEMENT), ); @@ -375,7 +375,7 @@ export function channel(capacity: number = 32): [Sender, Receiver] { state[IDX_RX_COUNT] = 1; const initialData = new Array(capacity).fill(null); - const items = new SharedJsonBuffer(initialData); + const items = new SharedJsonBuffer(initialData, options); const internals = new ChannelInternals( state,