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

Object Transforms not working well with stream.compose #114

Open
WRtux opened this issue Dec 3, 2022 · 0 comments
Open

Object Transforms not working well with stream.compose #114

WRtux opened this issue Dec 3, 2022 · 0 comments

Comments

@WRtux
Copy link

WRtux commented Dec 3, 2022

Putting Transforms created by through2.obj first when using stream.compose function (introduced in Node.js 16) with object inputs causes type error, just like putting non-object Transforms in it does. Nevertheless, putting normal Transforms created by its constructor first and through2.obj in the middle works right.

Though using normal Transforms avoids the problem, as a lot of plugins like in gulp use through2 internally, it would be nice if this can be fixed.

Node version: v16.17.1

Snippet:

stream.Readable.from([{}])
    .pipe(stream.compose(
        require('through2').obj((chunk, enc, callback) => callback(null, chunk))
    ));

The error log:

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of File
    at new NodeError (node:internal/errors:387:5)
    at _write (node:internal/streams/writable:314:13)
    at ComposeDuplex.Writable.write (node:internal/streams/writable:336:10)
    at Readable.ondata (node:internal/streams/readable:754:22)
    at Readable.emit (node:events:513:28)
    at Readable.emit (node:domain:552:15)
    at addChunk (node:internal/streams/readable:315:12)
    at readableAddChunk (node:internal/streams/readable:289:9)
    at Readable.push (node:internal/streams/readable:228:10)
    at Projects\...\node_modules\fork-stream\index.js:51:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant