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
base: master
from

Conversation

Projects
None yet
8 participants
@kaelzhang
Contributor

kaelzhang commented May 24, 2018

Refs: #20923

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
@apapirovski

LGTM but we could make the condition simpler (or, well, get rid of it).

@@ -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 ?

This comment has been minimized.

@apapirovski

apapirovski May 24, 2018

Member

Actually, could you do this instead: Stream.prototype.removeAllListeners.apply(this, arguments)?

This comment has been minimized.

@kaelzhang

kaelzhang May 24, 2018

Contributor

You're right.

@mscdex

This comment has been minimized.

Contributor

mscdex commented May 24, 2018

Perhaps a better fix might be to change removeAllListeners() instead (although would be semver-major)?

@ryzokuken

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();

This comment has been minimized.

@ryzokuken

ryzokuken May 24, 2018

Member

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?

This comment has been minimized.

@kaelzhang

kaelzhang May 24, 2018

Contributor

OK,I'll fix it

This comment has been minimized.

@kaelzhang

kaelzhang May 24, 2018

Contributor

I've changed the test a little bit. Any suggestions?

@lpinca

lpinca approved these changes May 24, 2018

@apapirovski

This comment has been minimized.

Member

apapirovski commented May 24, 2018

Perhaps a better fix might be to change removeAllListeners() instead (although would be semver-major)?

I don't think EE#removeAllListeners is doing anything wrong though, is it? Right now undefined would be converted to string (so undefined event) in both addListener and removeListener. This behaviour has been around since Node's beginning, afaik.

@mscdex

This comment has been minimized.

Contributor

mscdex commented May 24, 2018

Right now undefined would be converted to string (so undefined event) in both addListener and removeListener. This behaviour has been around since Node's beginning, afaik.

Which is why I said it'd be semver-major. I can't imagine anyone relying on undefined being converted to 'undefined' though.

@BridgeAR

This comment has been minimized.

Member

BridgeAR commented May 24, 2018

I agree with @mscdex that it would be best to change addListener and removeListener. Relying on undefined would be very surprising.

@mcollina

LGTM

@mcollina

This comment has been minimized.

@BridgeAR

This comment has been minimized.

Member

BridgeAR commented May 28, 2018

@apapirovski @mcollina @lpinca is anyone of you strongly in favor of this over just fixing not converting undefined to 'undefined' in the underlying function? I definitely think that would be the better solution even though it is semver-major.

@mcollina

This comment has been minimized.

Member

mcollina commented May 28, 2018

@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.

@apapirovski

This comment has been minimized.

Member

apapirovski commented May 28, 2018

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.

@mcollina

This comment has been minimized.

Member

mcollina commented May 28, 2018

CI failures are unrelated. This can land.

@mcollina

This comment has been minimized.

@mcollina

This comment has been minimized.

Member

mcollina commented May 28, 2018

Landed as 9f4bf4c.

@mcollina mcollina closed this May 28, 2018

mcollina added a commit that referenced this pull request May 28, 2018

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>

MylesBorins added a commit that referenced this pull request May 29, 2018

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>

@MylesBorins MylesBorins referenced this pull request May 29, 2018

Merged

v10.3.0 proposal #21011

MylesBorins added a commit that referenced this pull request May 29, 2018

2018-05-29, Version 10.3.0 (Current)
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

MylesBorins added a commit that referenced this pull request May 29, 2018

2018-05-29, Version 10.3.0 (Current)
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

MylesBorins added a commit that referenced this pull request May 29, 2018

2018-05-29, Version 10.3.0 (Current)
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

shisama added a commit to shisama/node that referenced this pull request May 30, 2018

stream: fix removeAllListeners() for Stream.Readable
Fixes: nodejs#20923

PR-URL: nodejs#20924
Refs: nodejs#20923
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

shisama added a commit to shisama/node that referenced this pull request May 30, 2018

2018-05-29, Version 10.3.0 (Current)
Notable Changes:

* **deps**:
  - upgrade npm to 6.1.0 (Rebecca Turner)
    nodejs#20190
* **fs**:
  - fix reads with pos \> 4GB (Mathias Buus)
    nodejs#21003
* **net**:
  - new option to allow IPC servers to be readable and writable
    by all users (Bartosz Sosnowski)
    nodejs#19472
* **stream**:
  - fix removeAllListeners() for Stream.Readable to work as expected
    when no arguments are passed (Kael Zhang)
    nodejs#20924
* **Added new collaborators**
  - John-David Dalton (https://github.com/jdalton)

PR-URL: nodejs#21011

shisama added a commit to shisama/node that referenced this pull request May 30, 2018

stream: fix removeAllListeners() for Stream.Readable
Fixes: nodejs#20923

PR-URL: nodejs#20924
Refs: nodejs#20923
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

shisama added a commit to shisama/node that referenced this pull request Jun 5, 2018

stream: fix removeAllListeners() for Stream.Readable
Fixes: nodejs#20923

PR-URL: nodejs#20924
Refs: nodejs#20923
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

shisama added a commit to shisama/node that referenced this pull request Jun 5, 2018

2018-05-29, Version 10.3.0 (Current)
Notable Changes:

* **deps**:
  - upgrade npm to 6.1.0 (Rebecca Turner)
    nodejs#20190
* **fs**:
  - fix reads with pos \> 4GB (Mathias Buus)
    nodejs#21003
* **net**:
  - new option to allow IPC servers to be readable and writable
    by all users (Bartosz Sosnowski)
    nodejs#19472
* **stream**:
  - fix removeAllListeners() for Stream.Readable to work as expected
    when no arguments are passed (Kael Zhang)
    nodejs#20924
* **Added new collaborators**
  - John-David Dalton (https://github.com/jdalton)

PR-URL: nodejs#21011

shisama added a commit to shisama/node that referenced this pull request Jun 9, 2018

stream: fix removeAllListeners() for Stream.Readable
Fixes: nodejs#20923

PR-URL: nodejs#20924
Refs: nodejs#20923
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

shisama added a commit to shisama/node that referenced this pull request Jun 9, 2018

2018-05-29, Version 10.3.0 (Current)
Notable Changes:

* **deps**:
  - upgrade npm to 6.1.0 (Rebecca Turner)
    nodejs#20190
* **fs**:
  - fix reads with pos \> 4GB (Mathias Buus)
    nodejs#21003
* **net**:
  - new option to allow IPC servers to be readable and writable
    by all users (Bartosz Sosnowski)
    nodejs#19472
* **stream**:
  - fix removeAllListeners() for Stream.Readable to work as expected
    when no arguments are passed (Kael Zhang)
    nodejs#20924
* **Added new collaborators**
  - John-David Dalton (https://github.com/jdalton)

PR-URL: nodejs#21011

shisama added a commit to shisama/node that referenced this pull request Jun 11, 2018

stream: fix removeAllListeners() for Stream.Readable
Fixes: nodejs#20923

PR-URL: nodejs#20924
Refs: nodejs#20923
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

shisama added a commit to shisama/node that referenced this pull request Jun 11, 2018

2018-05-29, Version 10.3.0 (Current)
Notable Changes:

* **deps**:
  - upgrade npm to 6.1.0 (Rebecca Turner)
    nodejs#20190
* **fs**:
  - fix reads with pos \> 4GB (Mathias Buus)
    nodejs#21003
* **net**:
  - new option to allow IPC servers to be readable and writable
    by all users (Bartosz Sosnowski)
    nodejs#19472
* **stream**:
  - fix removeAllListeners() for Stream.Readable to work as expected
    when no arguments are passed (Kael Zhang)
    nodejs#20924
* **Added new collaborators**
  - John-David Dalton (https://github.com/jdalton)

PR-URL: nodejs#21011

shisama added a commit to shisama/node that referenced this pull request Jun 12, 2018

stream: fix removeAllListeners() for Stream.Readable
Fixes: nodejs#20923

PR-URL: nodejs#20924
Refs: nodejs#20923
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

shisama added a commit to shisama/node that referenced this pull request Jun 12, 2018

2018-05-29, Version 10.3.0 (Current)
Notable Changes:

* **deps**:
  - upgrade npm to 6.1.0 (Rebecca Turner)
    nodejs#20190
* **fs**:
  - fix reads with pos \> 4GB (Mathias Buus)
    nodejs#21003
* **net**:
  - new option to allow IPC servers to be readable and writable
    by all users (Bartosz Sosnowski)
    nodejs#19472
* **stream**:
  - fix removeAllListeners() for Stream.Readable to work as expected
    when no arguments are passed (Kael Zhang)
    nodejs#20924
* **Added new collaborators**
  - John-David Dalton (https://github.com/jdalton)

PR-URL: nodejs#21011

shisama added a commit to shisama/node that referenced this pull request Jun 17, 2018

stream: fix removeAllListeners() for Stream.Readable
Fixes: nodejs#20923

PR-URL: nodejs#20924
Refs: nodejs#20923
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>

shisama added a commit to shisama/node that referenced this pull request Jun 17, 2018

2018-05-29, Version 10.3.0 (Current)
Notable Changes:

* **deps**:
  - upgrade npm to 6.1.0 (Rebecca Turner)
    nodejs#20190
* **fs**:
  - fix reads with pos \> 4GB (Mathias Buus)
    nodejs#21003
* **net**:
  - new option to allow IPC servers to be readable and writable
    by all users (Bartosz Sosnowski)
    nodejs#19472
* **stream**:
  - fix removeAllListeners() for Stream.Readable to work as expected
    when no arguments are passed (Kael Zhang)
    nodejs#20924
* **Added new collaborators**
  - John-David Dalton (https://github.com/jdalton)

PR-URL: nodejs#21011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment