I'm facing a weird issue with the readable-stream and buffer packages on a specific case. Using both of these packages to ensure the expected behavior happens on both NodeJS and browser environments.
Environment
readable-stream@3.6.0
buffer@6.0.3
// snippet to replicate this case
import { Readable } from "readable-stream";
import { Buffer } from "buffer";
import { createWriteStream } from "fs";
import { finished } from "stream/promises";
const buf = Buffer.from("H4sIAAAAAAACE+2U3Y6DIBCFfRTC3laLCGj7NqMOLbv+BXTb2Pjui15ssk32rjHZDd8Fk5wJzEzgoBszDGhntH08QPUBF0zeXd9FL4QxpoQga/Q8R8Y4FyQVWZZLLlXOCUsFU9Lnox2Y3AjWt/KCIX8M90d40A5apGeKd2iHBmOgB/qJ1pm+8ypLWJJ6RZsGHT0/6NFN5eU6H0d047bEkHhpTbW1dFPrN0lQ+lQWUKSoZcVLxcVJFFAC17JWej3PmdkXFfmyHGiNA3Y1dpXZSixLFNiNX+4z2tP/TOZP/s9kKoL/9+CNjFfjyOpvcgNHKoswYk10b8n2HCpwSL4/h2CYQCAQ+Cd8AeQkjmAADAAA", "base64");
const stream = Readable.from(buf);
finished(stream.pipe(createWriteStream('test'))).then(console.log, console.error);
Expected Behavior
The stream to be consumed by the Buffer's ArrayBuffer
Actual Behavior
The readable-stream pushes a number instead of a Buffer or ArrayLike. (seems like it pushes the number 31)
TypeError: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received type number (31)
at Readable.ondata (../../node_modules/readable-stream/lib/_stream_readable.js:681:20)
at addChunk (../../node_modules/readable-stream/lib/_stream_readable.js:298:12)
at readableAddChunk (../../node_modules/readable-stream/lib/_stream_readable.js:280:11)
at Readable.Object.<anonymous>.Readable.push (../../node_modules/readable-stream/lib/_stream_readable.js:241:10)
at ../../node_modules/readable-stream/lib/internal/streams/from.js:49:29
I'm facing a weird issue with the
readable-stream
andbuffer
packages on a specific case. Using both of these packages to ensure the expected behavior happens on both NodeJS and browser environments.Environment
Expected Behavior
The stream to be consumed by the Buffer's ArrayBuffer
Actual Behavior
The
readable-stream
pushes a number instead of a Buffer or ArrayLike. (seems like it pushes the number 31)