Permalink
Browse files

stream: fix removeAllListeners() for Stream.Readable

Fixes: #20923

PR-URL: #20924
Refs: #20923
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
  • Loading branch information...
kaelzhang authored and mcollina committed May 24, 2018
1 parent 4dbfb09 commit 9f4bf4ca43bc40f68a05c87081a9bae8736515b1
Showing with 14 additions and 1 deletion.
  1. +1 −1 lib/_stream_readable.js
  2. +13 −0 test/parallel/test-stream-readable-event.js
@@ -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
@@ -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);
}

0 comments on commit 9f4bf4c

Please sign in to comment.