You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
stream/iter: Broadcast.from() does not normalize byte inputs like from() #64081
import{Broadcast,text}from'node:stream/iter';asyncfunctionreadBroadcast(input){const{ broadcast }=Broadcast.from(input);returnawaittext(broadcast.push());}asyncfunctionshow(label,input){try{constdata=awaitreadBroadcast(input);console.log(`${label}: ok ${JSON.stringify(data)}`);}catch(error){console.log(`${label}: ${error.code??error.name}: ${error.message}`);}}awaitshow("Broadcast.from(['abc'])",['abc']);awaitshow("Broadcast.from('abc')",'abc');awaitshow('Broadcast.from(new Uint8Array([97]))',newUint8Array([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
Activity
stream: normalize Broadcast.from() byte inputs
stream: normalize Broadcast.from() byte inputs
stream: normalize Broadcast.from() byte inputs