FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

stream: add auto-destroy mode by mafintosh · Pull Request #22795 · nodejs/node · GitHub

/ node Public

stream: add auto-destroy mode - #22795

Closed
mafintosh wants to merge 7 commits into
nodejs:masterfrom
mafintosh:auto-destroy-stream
Closed

stream: add auto-destroy mode#22795
mafintosh wants to merge 7 commits into
nodejs:masterfrom
mafintosh:auto-destroy-stream

Conversation

Copy link
Copy Markdown
Member
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

This adds a new options to the stream constructor called autoDestroy that is default false.
When autoDestroy is enabled .destroy() will automatically be called when the stream has ended and/or finished depending on whether it's a readable/writable/duplex.

This simplifies error handling / resource management for users as you can then always do your teardown logic in the destroy method.

Copy link
Copy Markdown
Collaborator

nodejs-github-bot added dont-land-on-v6.x http2 Issues or PRs related to the http2 subsystem. stream Issues and PRs related to the stream subsystem. labels Sep 10, 2018
mcollina added semver-minor PRs that contain new features and should be released in the next minor version. dont-land-on-v8.x labels Sep 10, 2018

Copy link
Copy Markdown
Member

@mafintosh I think it needs to call .destroy(err) whenever there is a emit('error'), at least in the streams classes and the option is enabled.

I think this is the first step to implement #20096, right?

Comment thread doc/api/stream.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

.destroy() -> `.destroy()`?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you provide the default value explicitly here?

Comment thread doc/api/stream.md Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ditto.

Comment thread lib/_stream_readable.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can't this just be inlined?

targos commented Sep 10, 2018
edited
Loading

Copy link
Copy Markdown
Member

It looks like the code in _stream_readable.js should be in _stream_writable.js and vice versa.

Comment thread doc/api/stream.md Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can you provide the default value explicitly here?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Can we maybe check the order of the events/destroy callback as well?

Copy link
Copy Markdown
Member

Gentle ping @mafintosh :)

@targos I think it’s this way around in order to support shutting down Duplex streams?

Copy link
Copy Markdown
Member Author

@addaleax i'll fix up the nits+comments

Copy link
Copy Markdown
Contributor

Seems like a good addition to me, minus others' comments.

Copy link
Copy Markdown
Member

semver-minor commits should contain metadata in the YAML changes section of the affected API.

Comment thread lib/internal/http2/compat.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Just to make sure I’m not missing anything – how does this change relate to the others?

mafintosh force-pushed the auto-destroy-stream branch 2 times, most recently from bb2cb3c to 387516c Compare October 26, 2018 14:08
mafintosh force-pushed the auto-destroy-stream branch from 387516c to ccc94a9 Compare October 26, 2018 14:13

mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM

Copy link
Copy Markdown
Member Author

Fixed all the nits @addaleax @targos @vsemozhetbyt @Fishrock123

Copy link
Copy Markdown
Member Author

mcollina left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

LGTM but I would like to see a CITGM run.

Comment thread doc/api/stream.md Outdated
pr-url: https://github.com/nodejs/node/pull/18438
description: >
Add `emitClose` option to specify if `'close'` is emitted on destroy
- version: TBD

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

is the value we put here TBD? I never remember.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

REPLACEME :)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ah right! Thanks, will fix

Copy link
Copy Markdown
Member Author

Copy link
Copy Markdown
Member Author

Copy link
Copy Markdown
Member Author

The CITGM runs seem to report similar errors on master + this PR, landing ...

Trott pushed a commit to Trott/io.js that referenced this pull request Oct 30, 2018
PR-URL: nodejs#22795
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>

Copy link
Copy Markdown
Member Author

Landed in f24b070

mafintosh closed this Oct 30, 2018
mafintosh deleted the auto-destroy-stream branch October 30, 2018 14:19
targos pushed a commit that referenced this pull request Nov 2, 2018
PR-URL: #22795
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
BethGriggs pushed a commit that referenced this pull request Apr 8, 2019
PR-URL: #22795
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
BethGriggs mentioned this pull request May 1, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

http2 Issues or PRs related to the http2 subsystem. 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.

10 participants


Back | FazBrowse Home | New Git URL