Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream.pipeline does not accept 'Buffer' as a valid first argument, even though it is an Iterable #37731

Closed
carlansley opened this issue Mar 12, 2021 · 0 comments
Labels
stream Issues and PRs related to the stream subsystem.

Comments

@carlansley
Copy link

carlansley commented Mar 12, 2021

  • v15.11.0
  • Darwin mbp16.local 20.3.0 Darwin Kernel Version 20.3.0: Thu Jan 21 00:07:06 PST 2021; root:xnu-7195.81.3~1/RELEASE_X86_64 x86_64
  • stream

What steps will reproduce the bug?

This issue is a continuation of #36437. Although Iterables are now supported, Buffer (which is an Iterable) is not.

const stream = require("stream");

async function main() {
    await stream.pipeline(
        /*stream1*/ Buffer.from('abc'),
        /*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, 14.15.5+.

What is the expected behavior?

For Buffer to be able to be used as a source/first argument. Note if Buffer.from('abc') is changed to Buffer.from('abc').values(), it behaves correctly.

What do you see instead?

> TypeError: stream.on is not a function
    at destroyer (node:internal/streams/pipeline:39:10)
    at Function.pipeline (node:internal/streams/pipeline:175:21)
    at main (REPL8:2:18)
    at REPL10:1:1
    at Script.runInThisContext (node:vm:131:12)
    at REPLServer.defaultEval (node:repl:522:29)
    at bound (node:domain:416:15)
    at REPLServer.runBound [as eval] (node:domain:427:12)
    at REPLServer.onLine (node:repl:844:10)
    at REPLServer.emit (node:events:390:22)

Additional information

@aduh95 aduh95 added the stream Issues and PRs related to the stream subsystem. label Mar 12, 2021
Linkgoron added a commit to Linkgoron/node that referenced this issue Mar 13, 2021
change isStream to also check existence of on, so it
wont mistake buffers as Streams.

fixes: nodejs#37731
Linkgoron added a commit to Linkgoron/node that referenced this issue Mar 13, 2021
change isStream to also check existence of on, so it
wont mistake buffers as Streams.

fixes: nodejs#37731
Linkgoron added a commit to Linkgoron/node that referenced this issue Mar 16, 2021
change isStream to also check existence of on, so it
wont mistake buffers as Streams.

fixes: nodejs#37731
ruyadorno pushed a commit that referenced this issue Mar 24, 2021
change isStream to also check existence of on, so it
wont mistake buffers as Streams.

fixes: #37731

PR-URL: #37739
Fixes: #37731
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
targos pushed a commit that referenced this issue Sep 4, 2021
change isStream to also check existence of on, so it
wont mistake buffers as Streams.

fixes: #37731

PR-URL: #37739
Fixes: #37731
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: Robert Nagy <[email protected]>
Reviewed-By: Benjamin Gruenbaum <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants