Current implementation assume stdin is always a binary stream, but it does not really check the type. So if pass Readable.from(string) as stdin, most time it works, unless the string contains non-ASCII characters, in such case, data is string and data.length is number of UTF16 code units, which will smaller than the number of UTF8 code units or bytes.
I suggest the implementation should either deal with the string case, or just throw type error if not buffer.
https://github.com/kubernetes-client/javascript/blob/b4fd82f2d20e46ad6a60f9b83c38553f5674a4dc/src/web-socket-handler.ts#L58
Current implementation assume stdin is always a binary stream, but it does not really check the type. So if pass
Readable.from(string)
as stdin, most time it works, unless the string contains non-ASCII characters, in such case,data
is string anddata.length
is number of UTF16 code units, which will smaller than the number of UTF8 code units or bytes.I suggest the implementation should either deal with the string case, or just throw type error if not buffer.