Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream: fix removeAllListeners() for Stream.Readable #20924

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/_stream_readable.js
Original file line number Diff line number Diff line change
Expand Up @@ -846,7 +846,7 @@ Readable.prototype.removeListener = function(ev, fn) {
};

Readable.prototype.removeAllListeners = function(ev) {
const res = Stream.prototype.removeAllListeners.call(this, ev);
const res = Stream.prototype.removeAllListeners.apply(this, arguments);

if (ev === 'readable' || ev === undefined) {
// We need to check if there is someone still listening to
Expand Down
13 changes: 13 additions & 0 deletions test/parallel/test-stream-readable-event.js
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,16 @@ const Readable = require('stream').Readable;
assert.deepStrictEqual(result, expected);
}));
}

{
// #20923
const r = new Readable();
r._read = function() {
// actually doing thing here
};
r.on('data', function() {});

r.removeAllListeners();

assert.strictEqual(r.eventNames().length, 0);
}