Closed
Description
- Version: v16.1.0
- Platform: Darwin Carls-iMac-Pro.local 20.4.0 Darwin Kernel Version 20.4.0: Thu Apr 22 21:46:47 PDT 2021; root:xnu-7195.101.2~1/RELEASE_X86_64 x86_64
- Subsystem: stream
What steps will reproduce the bug?
This corner-case issue is another continuation of #36437. Although Iterables are now supported, zero-length strings are not.
const stream = require("stream");
async function main() {
await stream.pipeline(
/*stream1*/ '',
/*stream2*/ new stream.PassThrough({ objectMode: true }),
/*callback*/ () => { console.log("done"); });
}
main().catch(e => console.error(e));
How often does it reproduce? Is there a required condition?
Reproduces in all versions of Node tested, 16+.
What is the expected behavior?
For a zero-length string to be able to be used as a source/first argument. Strings with non-zero lengths work correctly.
What do you see instead?
TypeError [ERR_INVALID_ARG_TYPE]: The "source" argument must be of type function or an instance of Stream, Iterable, or AsyncIterable. Received type string ('')
at Function.pipeline (internal/streams/pipeline.js:202:15)
at main (REPL8:2:18)
at REPL10:1:1
at Script.runInThisContext (vm.js:133:18)
at REPLServer.defaultEval (repl.js:486:29)
at bound (domain.js:416:15)
at REPLServer.runBound [as eval] (domain.js:427:12)
at REPLServer.onLine (repl.js:819:10)
at REPLServer.emit (events.js:388:22)
at REPLServer.emit (domain.js:470:12) {
code: 'ERR_INVALID_ARG_TYPE'
}