stream: fix removeAllListeners() for Stream.Readable
Fixes: https://github.com/nodejs/node/issues/20923 PR-URL: https://github.com/nodejs/node/pull/20924 Refs: https://github.com/nodejs/node/issues/20923 Reviewed-By: Anatoli Papirovski <apapirovski@mac.com> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
This commit is contained in:
parent
4dbfb096f0
commit
9f4bf4ca43
@ -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);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user