Skip to content

Allow passing buffer size options to channel()#19

Merged
W4G1 merged 1 commit into
W4G1:mainfrom
brianjenkins94:channel-buffer-size
Mar 26, 2026
Merged

Allow passing buffer size options to channel()#19
W4G1 merged 1 commit into
W4G1:mainfrom
brianjenkins94:channel-buffer-size

Conversation

@brianjenkins94

Copy link
Copy Markdown
Contributor

Summary

  • Threads the options parameter through from channel() to the underlying SharedJsonBuffer constructor
  • SharedJsonBuffer already accepts { size?: number } but channel() wasn't exposing it, making it impossible to override the default 64KB buffer limit
  • Enables: const [tx, rx] = channel(32, { size: 1024 * 1024 * 5 })

Context

When sending large messages (e.g. objects with thousands of keys) through a channel, the default 64KB SharedJsonBuffer overflows with RangeError: offset is out of bounds. Related: #15

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 });
@W4G1

W4G1 commented Mar 26, 2026

Copy link
Copy Markdown
Owner

Thanks! Looks good to me. I'll publish it in a new version soon.

@W4G1 W4G1 merged commit a42ce15 into W4G1:main Mar 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants