Version
main
Platform
Subsystem
stream
What steps will reproduce the bug?
import { Broadcast, text } from 'node:stream/iter';
async function readBroadcast(input) {
const { broadcast } = Broadcast.from(input);
return await text(broadcast.push());
}
async function show(label, input) {
try {
const data = await readBroadcast(input);
console.log(`${label}: ok ${JSON.stringify(data)}`);
} catch (error) {
console.log(`${label}: ${error.code ?? error.name}: ${error.message}`);
}
}
await show("Broadcast.from(['abc'])", ['abc']);
await show("Broadcast.from('abc')", 'abc');
await show('Broadcast.from(new Uint8Array([97]))', new Uint8Array([97]));
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Broadcast.from(['abc']): ok "abc"
Broadcast.from('abc'): ok "abc"
Broadcast.from(new Uint8Array([97])): ok "a"
Broadcast.from() to normalize byte inputs consistently with from(), so strings and Uint8Array inputs broadcast as byte chunks.
What do you see instead?
Broadcast.from(['abc']): ok "abc"
Broadcast.from('abc'): ERR_INVALID_ARG_TYPE: The "input" argument must be an instance of Broadcastable, AsyncIterable, or Iterable. Received type string ('abc')
Broadcast.from(new Uint8Array([97])): ERR_INVALID_ARG_TYPE: The "chunk" argument must be of type string or an instance of Uint8Array. Received type number (97)
Broadcast.from(['abc']) broadcasts "abc", but Broadcast.from('abc') rejects the string input and Broadcast.from(new Uint8Array([97])) iterates the byte values and fails on 97
Additional information
No response
Version
main
Platform
Subsystem
stream
What steps will reproduce the bug?
How often does it reproduce? Is there a required condition?
Always
What is the expected behavior? Why is that the expected behavior?
Broadcast.from()to normalize byte inputs consistently withfrom(), so strings andUint8Arrayinputs broadcast as byte chunks.What do you see instead?
Broadcast.from(['abc'])broadcasts"abc", butBroadcast.from('abc')rejects the string input andBroadcast.from(new Uint8Array([97]))iterates the byte values and fails on97Additional information
No response