Skip to content

Uncatchable error when upload stream is used in failed pipeline. #2560

@thebenperson

Description

@thebenperson

Please make sure you have searched for information in the following guides.

A screenshot that you have tested with "Try this API".

N/A. This issue seems to be related to the client library's error handling ability and not the underlying API.

Link to the code that reproduces this issue. A link to a public Github Repository or gist with a minimal reproduction.

https://gist.github.com/thebenperson/c6c1e66653fdc8c05cab52726b2f0664

A step-by-step description of how to reproduce the issue, based on the linked reproduction.

  1. Create a readable input stream.
  2. Create a writable output stream by calling File.createWriteStream().
  3. Call Stream.promises.pipeline(input, output).
  4. Have the input stream emit() an error before it can provide any data.

A clear and concise description of what the bug is, and what you expected to happen.

Expected behavior: Stream.promises.pipeline() promise is rejected.
Actual behavior: Program ends due to an unhandled "error" event.

I might have found the problem.

The error from the input stream is passed on to the output stream.
But, no data has been provided from the input stream yet.

This means that this callback hasn't been called yet:

writeStream.once('writing', () => {

Meaning pipeline() hasn't been called here yet:

pipeline(

So that means that there is nothing to handle errors when
emitStream.destroy(e) is called here:

emitStream.destroy(e);

A clear and concise description WHY you expect this behavior, i.e., was it a recent change, there is documentation that points to this behavior, etc. **

Other types of writable streams do not cause errors like this one.
The writable stream from this library is interfering with the pipeline() function's ability to handle errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    api: storageIssues related to the googleapis/nodejs-storage API.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions