Skip to content

Legacy stream throws unhandled stream error when it is handled #35237

Closed
@szmarczak

Description

@szmarczak
  • Version: 14.11.0
  • Platform: Linux solus 5.6.19-158.current #1 SMP PREEMPT Sun Jul 26 14:17:01 UTC 2020 x86_64 GNU/Linux
  • Subsystem: stream

What steps will reproduce the bug?

const {Stream: LegacyStream, PassThrough} = require('stream');

const destination = new PassThrough();
destination.once('error', () => {});

const stream = new LegacyStream();
stream.pipe(destination);

destination.destroy(new Error('this should be handled'));

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

Always.

What is the expected behavior?

No error.

What do you see instead?

internal/streams/legacy.js:61
      throw er; // Unhandled stream error in pipe.
      ^

Error: this should be handled
    at Object.<anonymous> (/home/szm/Desktop/got/demo.js:9:21)
    at Module._compile (internal/modules/cjs/loader.js:1076:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1097:10)
    at Module.load (internal/modules/cjs/loader.js:941:32)
    at Function.Module._load (internal/modules/cjs/loader.js:782:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47

Additional information

sindresorhus/got#887

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions