Skip to content

Creating Transform from stream/web.TransformStream emits ERR_INVALID_ARG_TYPE on third write #42157

@isaacs

Description

@isaacs

Version

17.6.0

Platform

Darwin moxy.lan 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan 5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64

Subsystem

stream, stream/web

What steps will reproduce the bug?

const { TransformStream: WebTS } = require('stream/web')
const { Transform: NodeTS } = require('stream')

const s = NodeTS.fromWeb(new WebTS())
s.pipe(process.stderr)
s.write(Buffer.from('hello'))
s.write(Buffer.from('hello'))
s.write(Buffer.from('hello'))
s.write(Buffer.from('hello'))
s.write(Buffer.from('hello'))
s.end()

/*
hellonode:events:505
      throw er; // Unhandled 'error' event
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Object
    at new NodeError (node:internal/errors:372:5)
    at readableAddChunk (node:internal/streams/readable:266:13)
    at Duplex.Readable.push (node:internal/streams/readable:234:10)
    at node:internal/webstreams/adapters:719:20
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Duplex instance at:
    at emitErrorNT (node:internal/streams/destroy:164:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v17.6.0
*/

How often does it reproduce? Is there a required condition?

always

What is the expected behavior?

Should print "hellohellohellohellohello" to stderr.

What do you see instead?

hellonode:events:505
      throw er; // Unhandled 'error' event
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Object
    at new NodeError (node:internal/errors:372:5)
    at readableAddChunk (node:internal/streams/readable:266:13)
    at Duplex.Readable.push (node:internal/streams/readable:234:10)
    at node:internal/webstreams/adapters:719:20
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
Emitted 'error' event on Duplex instance at:
    at emitErrorNT (node:internal/streams/destroy:164:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at processTicksAndRejections (node:internal/process/task_queues:83:21) {
  code: 'ERR_INVALID_ARG_TYPE'
}

Node.js v17.6.0

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues with confirmed bugs.streamIssues and PRs related to the stream subsystem.web streams

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions