Open guest271314 opened 5 months ago
Looks like Bun only reads either a certain number of times or a certain amount of data from Bun.stdin.stream()
.
Or, the resizable ArrayBuffer
implementation has an internal limit that is under 1 MB.
For the same input of 209715 length array encoded as JSON (1 MB) Node.js and Deno each read 16 times and the entire input stream. Bun reads 5 times and stops short of reading the entire input, thus never echoes back the Array(209715)
to the client.
Bun.file("/dev/stdin").stream()
and Bun.file("/proc/self/fd/0").stream()
achieve the expected result.
Bun.stdin.stream()
and Bun.file(0).stream()
do not ahcieve the expected result, consistently hang on 983036
bytes of 1048576
bytes expected.
Bun.stdin.stream()
does not behave the same as Bun.file()
.
Re-reading the guides https://bun.sh/guides/process/stdin it's not clear if Bun.file()
and Bun.stdin
are intended to be synonymous.
Bun also exposes stdin as a
BunFile
viaBun.stdin
. This is useful for incrementally reading large inputs that are piped into thebun
process.
What version of Bun is running?
v1.1.12 i
What platform is your computer?
x64
What steps can reproduce the bug?
Follow these instructions https://github.com/guest271314/native-messaging-bun/tree/main
Point to this Native Messaging host https://github.com/guest271314/NativeMessagingHosts/blob/4878edcb14401d3f2b5aac08448f8e0f0916956a/nm_host.js in
nm_bun.js
where all that is needed is the shebang lineWhat is the expected behavior?
Bun Native Messaging host to echo back an
Array
having length209715
based on https://github.com/guest271314/native-messaging-bun/blob/main/background.js#L6C1-L6C37The same code run in Bun, Deno, and Node.js runtime environments worked as of this commit https://github.com/guest271314/NativeMessagingHosts/commit/4878edcb14401d3f2b5aac08448f8e0f0916956
What do you see instead?
The
Array
is never sent back to the Native Messaging client (Chromium 127 Developer Build).Additional information
The same code still works
nm_host.js
still works usingdeno
version 1.44. There are three (3) DevTools windows open in the screenshot; Bun Native Messaging extension window is on top, then Deno then Node.js. Notice the windows underneath have arrays with length at 209715 where the Bun host does not send back the message to the client and will exit when sending a sencond message andnode
version v23.0.0-nightly20240526aaca18b54e. Deno and Node.js handle subsequent messages.