Skip to content
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: don't emit end after close #33076

Closed
wants to merge 1 commit into from

Conversation

ronag
Copy link
Member

@ronag ronag commented Apr 26, 2020

Readable stream could emit 'end' after 'close'.

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

@ronag ronag added stream Issues and PRs related to the stream subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. labels Apr 26, 2020
@ronag ronag force-pushed the stream-end-after-close branch from 841f7af to 879ab7c Compare April 26, 2020 09:41
@ronag ronag marked this pull request as ready for review April 26, 2020 09:41
@ronag ronag force-pushed the stream-end-after-close branch from 879ab7c to b36eed4 Compare April 26, 2020 09:41
@@ -113,7 +113,7 @@ const assert = require('assert');
read.destroy();

read.removeListener('end', fail);
read.on('end', common.mustCall());
read.on('end', common.mustNotCall());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE, possible breaking change

@@ -124,7 +124,7 @@ const assert = require('assert');

duplex.removeListener('end', fail);
duplex.removeListener('finish', fail);
duplex.on('end', common.mustCall());
duplex.on('end', common.mustNotCall());
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NOTE, possible breaking change

@ronag
Copy link
Member Author

ronag commented Apr 26, 2020

Please note that this can have breaking consequences. Though this PR ensures "proper" behaviour the ecosystem might make incorrect assumptions that this PR breaks.

Would appreciate some feedback and thoughts on the risks. @nodejs/streams @mafintosh

@nodejs-github-bot
Copy link
Collaborator

@ronag ronag force-pushed the stream-end-after-close branch 2 times, most recently from f7b791b to 4ee7287 Compare April 26, 2020 09:45
@ronag ronag changed the title stream: don't emit end after closei stream: don't emit end after close Apr 26, 2020
Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a feeling this would be too breaking.

@ronag
Copy link
Member Author

ronag commented Apr 26, 2020

I have a feeling this would be too breaking.

I suspected soo. Anyway, we are aware of this issue and maybe we can revisit this at a later point. We've got quite a lot of recent semver-major stuff so it might be a good idea to wait regardless.

Should I document this "known issue" somewhere somehow?

@mcollina
Copy link
Member

Documenting it's a good idea.

@vweevers
Copy link
Contributor

On the other hand, the documentation has stated for 5 years now (db4cb33) that the close event "indicates that no more events will be emitted".

@mcollina
Copy link
Member

I would say let’s fix this. It would be good if we had an opt-out flag.

@ronag
Copy link
Member Author

ronag commented Apr 27, 2020

It would be good if we had an opt-out flag.

I'm a little unsure about the value of this. If a library breaks because of this (which is still unlikely, but possible) it should not be much more difficult to actually fix the issue rather than having to add a flag?

Would it be an alternative to begin with no adding a flag, and then add it if this turns out to be a problem?

@nodejs-github-bot
Copy link
Collaborator

@mcollina
Copy link
Member

On the other hand, the documentation has stated for 5 years now (db4cb33) that the close event "indicates that no more events will be emitted".

hey @nodejs/tsc, do you think a commit that fixes that is semver-major? It's potentially breaking (see code), however it might be worthwhile landing in v14.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jasnell
Copy link
Member

jasnell commented Apr 27, 2020

Hmmm hard to say really. This change looks good to me, however.

Readable stream could emendd' after 'close'.
@ronag
Copy link
Member Author

ronag commented Apr 27, 2020

rebased to fix conflict

@ronag ronag force-pushed the stream-end-after-close branch from 4ee7287 to 412129c Compare April 27, 2020 15:53
@ronag ronag added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 27, 2020
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Apr 27, 2020

CI: https://ci.nodejs.org/job/node-test-pull-request/31013/ (:heavy_check_mark:)

@mcollina
Copy link
Member

After speaking with @mafintosh, let's go with a minor and see. I would not backport it to v12.

@mcollina mcollina removed the semver-major PRs that contain breaking changes and should be released in the next major version. label Apr 27, 2020
@mcollina mcollina added dont-land-on-v10.x semver-minor PRs that contain new features and should be released in the next minor version. labels Apr 27, 2020
ronag added a commit that referenced this pull request Apr 28, 2020
Readable stream could emit 'end' after 'close'.

PR-URL: #33076
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
@ronag
Copy link
Member Author

ronag commented Apr 28, 2020

Landed in f64c640

@ronag ronag closed this Apr 28, 2020
BethGriggs pushed a commit that referenced this pull request Apr 28, 2020
Readable stream could emit 'end' after 'close'.

PR-URL: #33076
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
BethGriggs added a commit that referenced this pull request Apr 28, 2020
Notable changes:

- deps: upgrade openssl sources to 1.1.1g (Hassaan Pasha)
  [#32971](#32971)
- doc: add juanarbol as collaborator (Juan José Arboleda)
  [#32906](#32906)
- http: doc deprecate abort and improve docs (Robert Nagy)
  [#32807](#32807)
- module: do not warn when accessing `__esModule` of unfinished exports
  (Anna Henningsen) [#33048](#33048)
- n-api: detect deadlocks in thread-safe function (Gabriel Schulhof)
  [#32860](#32860)
- src: deprecate embedder APIs with replacements (Anna Henningsen)
  [#32858](#32858)
- stream:
  - don't emit end after close (Robert Nagy)
    [#33076](#33076)
  - don't wait for close on legacy streams (Robert Nagy)
    [#33058](#33058)
  - pipeline should only destroy un-finished streams (Robert Nagy)
    [#32968](#32968)

PR-URL: #33103
@BethGriggs BethGriggs mentioned this pull request Apr 28, 2020
BethGriggs pushed a commit that referenced this pull request Apr 28, 2020
Readable stream could emit 'end' after 'close'.

PR-URL: #33076
Reviewed-By: Matteo Collina <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
BethGriggs added a commit that referenced this pull request Apr 28, 2020
Notable changes:

- deps: upgrade openssl sources to 1.1.1g (Hassaan Pasha)
  [#32971](#32971)
- doc: add juanarbol as collaborator (Juan José Arboleda)
  [#32906](#32906)
- http: doc deprecate abort and improve docs (Robert Nagy)
  [#32807](#32807)
- module: do not warn when accessing `__esModule` of unfinished exports
  (Anna Henningsen) [#33048](#33048)
- n-api: detect deadlocks in thread-safe function (Gabriel Schulhof)
  [#32860](#32860)
- src: deprecate embedder APIs with replacements (Anna Henningsen)
  [#32858](#32858)
- stream:
  - don't emit end after close (Robert Nagy)
    [#33076](#33076)
  - don't wait for close on legacy streams (Robert Nagy)
    [#33058](#33058)
  - pipeline should only destroy un-finished streams (Robert Nagy)
    [#32968](#32968)
- vm: add importModuleDynamically option to compileFunction (Gus Caplan)
  [#32985](#32985)

PR-URL: #33103
BethGriggs added a commit that referenced this pull request Apr 29, 2020
Notable changes:

- deps: upgrade openssl sources to 1.1.1g (Hassaan Pasha)
  [#32971](#32971)
- doc: add juanarbol as collaborator (Juan José Arboleda)
  [#32906](#32906)
- http: doc deprecate abort and improve docs (Robert Nagy)
  [#32807](#32807)
- module: do not warn when accessing `__esModule` of unfinished exports
  (Anna Henningsen) [#33048](#33048)
- n-api: detect deadlocks in thread-safe function (Gabriel Schulhof)
  [#32860](#32860)
- src: deprecate embedder APIs with replacements (Anna Henningsen)
  [#32858](#32858)
- stream:
  - don't emit end after close (Robert Nagy)
    [#33076](#33076)
  - don't wait for close on legacy streams (Robert Nagy)
    [#33058](#33058)
  - pipeline should only destroy un-finished streams (Robert Nagy)
    [#32968](#32968)
- vm: add importModuleDynamically option to compileFunction (Gus Caplan)
  [#32985](#32985)

PR-URL: #33103
BethGriggs added a commit that referenced this pull request Apr 29, 2020
Notable changes:

- deps: upgrade openssl sources to 1.1.1g (Hassaan Pasha)
  [#32971](#32971)
- doc: add juanarbol as collaborator (Juan José Arboleda)
  [#32906](#32906)
- http: doc deprecate abort and improve docs (Robert Nagy)
  [#32807](#32807)
- module: do not warn when accessing `__esModule` of unfinished exports
  (Anna Henningsen) [#33048](#33048)
- n-api: detect deadlocks in thread-safe function (Gabriel Schulhof)
  [#32860](#32860)
- src: deprecate embedder APIs with replacements (Anna Henningsen)
  [#32858](#32858)
- stream:
  - don't emit end after close (Robert Nagy)
    [#33076](#33076)
  - don't wait for close on legacy streams (Robert Nagy)
    [#33058](#33058)
  - pipeline should only destroy un-finished streams (Robert Nagy)
    [#32968](#32968)
- vm: add importModuleDynamically option to compileFunction (Gus Caplan)
  [#32985](#32985)

PR-URL: #33103
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. semver-minor PRs that contain new features and should be released in the next minor version. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants