Skip to content

The error handler isn't removed on successful stream async iteration #32995

@szmarczak

Description

@szmarczak
  • Version: v13.13.0
  • Platform: Linux solus 5.5.11-151.current deps: update openssl to 1.0.1j #1 SMP PREEMPT Tue Mar 24 18:06:46 UTC 2020 x86_64 GNU/Linux
  • Subsystem: stream

What steps will reproduce the bug?

const {Readable} = require('stream');

async function getBuffer(readable) {
	const chunks = [];

	for await (const chunk of readable) {
		chunks.push(chunk);
	}

	return Buffer.concat(chunks);
}

const stream = new Readable({
    read() {
        this.push('chunk');
        this.push(null);
    }
});

const buffer = await getBuffer(stream);

console.log(stream.listenerCount('error'));

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

Always.

What is the expected behavior?

0

What do you see instead?

1

Additional information

The error handler seems to be from https://github.com/nodejs/node/blob/master/lib/internal/streams/end-of-stream.js

Metadata

Metadata

Assignees

No one assigned

    Labels

    streamIssues and PRs related to the stream subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions