Skip to content

Commit 123437b

Browse files
ronagBridgeAR
authored andcommitted
stream: apply special logic in removeListener for readable.off()
We have special logic in removeListener() which must apply to off() as well. PR-URL: #29486 Reviewed-By: Benjamin Gruenbaum <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]>
1 parent 9150c4d commit 123437b

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

lib/_stream_readable.js

+1
Original file line numberDiff line numberDiff line change
@@ -908,6 +908,7 @@ Readable.prototype.removeListener = function(ev, fn) {
908908

909909
return res;
910910
};
911+
Readable.prototype.off = Readable.prototype.removeListener;
911912

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

test/parallel/test-stream-readable-readable-then-resume.js

+2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const common = require('../common');
44
const { Readable } = require('stream');
5+
const assert = require('assert');
56

67
// This test verifies that a stream could be resumed after
78
// removing the readable event in the same tick
@@ -24,6 +25,7 @@ function check(s) {
2425
const readableListener = common.mustNotCall();
2526
s.on('readable', readableListener);
2627
s.on('end', common.mustCall());
28+
assert.strictEqual(s.removeListener, s.off);
2729
s.removeListener('readable', readableListener);
2830
s.resume();
2931
}

0 commit comments

Comments
 (0)