Repository: node
Issue: Unable to catch error in piped streams | Uncaught TypeError [ERR_INVALID_ARG_TYPE]
Labels: stream

### Version

v14.18.1

### Platform

macOS Big Sur

### Subsystem

_No response_

### What steps will reproduce the bug?

When we pipe multiple streams and the data coming from the first stream is an array, then it is expected to have an error. But I am unable to catch this error in this case and it is throwing the below error.

**internal/streams/writable.js:285
      throw new ERR_INVALID_ARG_TYPE(
      ^

TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Array
    at new NodeError (internal/errors.js:322:7)
    at WriteStream.Writable.write (internal/streams/writable.js:285:13)
    at Stream.ondata (internal/streams/legacy.js:20:31)
    at Stream.emit (events.js:400:28)
    at drain (/Users/mayankkatare/Trainings/Node assignments/node_modules/through/index.js:36:16)
    at Stream.stream.queue.stream.push (/Users/mayankkatare/Trainings/Node assignments/node_modules/through/index.js:45:5)
    at Parser.parser.onValue (/Users/mayankkatare/Trainings/Node assignments/node_modules/JSONStream/index.js:118:16)
    at Parser.proto.emit (/Users/mayankkatare/Trainings/Node assignments/node_modules/jsonparse/jsonparse.js:337:8)
    at Parser.proto.pop (/Users/mayankkatare/Trainings/Node assignments/node_modules/jsonparse/jsonparse.js:332:8)
    at Parser.proto.onToken (/Users/mayankkatare/Trainings/Node assignments/node_modules/jsonparse/jsonparse.js:402:12) {
  code: 'ERR_INVALID_ARG_TYPE'
}**

**------Repro script--------**
```
const request = require('request');
const JSONStream = require('JSONStream')
const fs = require('fs')

let Url = 'http://localhost:5000/' // This url returns a response 

request(Url).on('response', respHandler)

function respHandler(res) {
  let jsonStream = JSONStream.parse(['data']) // Assuming response is {data:['Home page', 'Jackson']}
  
  var file = fs.createWriteStream('someNewFile.txt')
  try {
// Trying to catch error on each stream initially
    res.on('error', err => console.log(err));
    jsonStream.on('error', err => console.log(err));
    file.on('error', err => console.log(err));
    
// Trying to catch error during piping
    res.pipe(jsonStream).on('error', (err) => {
      console.log(err)
      if(err) {
        console.log(err);
      }
    }).pipe(file).on('error', (err) => {
      console.log(err)
      if(err) {
        console.log(err);
      }
    })
  } catch (error) {
    if(error)
    console.log(error);
  }
  
}
```

### How often does it reproduce? Is there a required condition?

Everytime

### What is the expected behavior?

It should throw an error but we should be able to handle this error so that our app should not crash. We should be able to catch the error in error event handler. This was the behaviour in 12.15.0 and it seems to have changed in 14.18.1

### What do you see instead?

Uncaught TypeError [ERR_INVALID_ARG_TYPE]: The "chunk" argument must be of type string or an instance of Buffer or Uint8Array. Received an instance of Array

### Additional information

_No response_