-
Notifications
You must be signed in to change notification settings - Fork 30k
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but we could make the condition simpler (or, well, get rid of it).
lib/_stream_readable.js
Outdated
@@ -846,7 +846,9 @@ Readable.prototype.removeListener = function(ev, fn) { | |||
}; | |||
|
|||
Readable.prototype.removeAllListeners = function(ev) { | |||
const res = Stream.prototype.removeAllListeners.call(this, ev); | |||
const res = arguments.length === 0 ? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, could you do this instead: Stream.prototype.removeAllListeners.apply(this, arguments)
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right.
771108d
to
24320ec
Compare
Perhaps a better fix might be to change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks nice, going forward, but I wasn't really satisfied by the unit test. Could you make the changes I asked for?
{ | ||
const r = new Readable(); | ||
|
||
r.removeAllListeners(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if you remove this line right here? Do the tests still pass? They probably should because we never added any listeners to begin with. Could you try adding a few listeners, assert that r.eventNames()
is non-zero, call this line and then assert it's zero please?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK,I'll fix it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the test a little bit. Any suggestions?
I don't think |
Which is why I said it'd be semver-major. I can't imagine anyone relying on |
I agree with @mscdex that it would be best to change |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@apapirovski @mcollina @lpinca is anyone of you strongly in favor of this over just fixing not converting |
@BridgeAR this fix a bad bug which could lead a potential memory leak. If you want to change the underlining function in a semver-major might be a good call to avoid this in the future. |
This should just land barring the CI being red. I'm whatever on the other change... if people want to, fine by me but I don't really care either way. |
CI failures are unrelated. This can land. |
Landed as 9f4bf4c. |
Notable Changes: * **deps**: - upgrade npm to 6.1.0 (Rebecca Turner) #20190 * **fs**: - fix reads with pos \> 4GB (Mathias Buus) #21003 * **net**: - new option to allow IPC servers to be readable and writable by all users (Bartosz Sosnowski) #19472 * **stream**: - fix removeAllListeners() for Stream.Readable to work as expected when no arguments are passed (Kael Zhang) #20924 * **Added new collaborators** - John-David Dalton (https://github.com/jdalton) PR-URL: #21011
Notable Changes: * **deps**: - upgrade npm to 6.1.0 (Rebecca Turner) #20190 * **fs**: - fix reads with pos \> 4GB (Mathias Buus) #21003 * **net**: - new option to allow IPC servers to be readable and writable by all users (Bartosz Sosnowski) #19472 * **stream**: - fix removeAllListeners() for Stream.Readable to work as expected when no arguments are passed (Kael Zhang) #20924 * **Added new collaborators** - John-David Dalton (https://github.com/jdalton) PR-URL: #21011
Notable Changes: * **deps**: - upgrade npm to 6.1.0 (Rebecca Turner) #20190 * **fs**: - fix reads with pos \> 4GB (Mathias Buus) #21003 * **net**: - new option to allow IPC servers to be readable and writable by all users (Bartosz Sosnowski) #19472 * **stream**: - fix removeAllListeners() for Stream.Readable to work as expected when no arguments are passed (Kael Zhang) #20924 * **Added new collaborators** - John-David Dalton (https://github.com/jdalton) PR-URL: #21011
This change is necessary for Electron 3 to a bug in Node.js 10.2.x which causes the `removeAllListeners` method to no longer remove all listeners for any event name when no argument is passed: nodejs/node#20924 This issue has been fixed in Node.js 10.3.0+ so we will have to remove this workaround when we move to Electron 4.0 to avoid future event handler leaks.
This change is necessary for Electron 3 to a bug in Node.js 10.2.x which causes the `removeAllListeners` method to no longer remove all listeners for any event name when no argument is passed: nodejs/node#20924 This issue has been fixed in Node.js 10.3.0+ so we will have to remove this workaround when we move to Electron 4.0 to avoid future event handler leaks.
This change is necessary for Electron 3 to a bug in Node.js 10.2.x which causes the `removeAllListeners` method to no longer remove all listeners for any event name when no argument is passed: nodejs/node#20924 This issue has been fixed in Node.js 10.3.0+ so we will have to remove this workaround when we move to Electron 4.0 to avoid future event handler leaks.
Refs: #20923
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes