Skip to content

stream: add AbortSignal support to finished - #37354

Merged
aduh95 merged 1 commit into
nodejs:masterfrom
Linkgoron:stream-finished-abort-signal
Feb 26, 2021
Merged

stream: add AbortSignal support to finished#37354
aduh95 merged 1 commit into
nodejs:masterfrom
Linkgoron:stream-finished-abort-signal

Conversation

@Linkgoron

@LinkgoronLinkgoron commented Feb 13, 2021

Copy link
Copy Markdown
Contributor

Add AbortSignal support to stream.finished
This PR adds support for AbortSignal in stream.finished (eos).

Originally, I thought about adding it to the promisified version only, however I think that it could be useful to both.

I've implemented it so that if the stream is already closed, and the AbortSignal is also aborted, the closed gets prioritised (no error is emitted).

  • 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

@aduh95aduh95 left a comment

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.

Can you add an entry to the changes YAML list in the docs please?

 - version: REPLACEMEpr-url: https://github.com/nodejs/node/pull/37354description: The `signal` option was added.

Comment threadlib/internal/streams/end-of-stream.js Outdated
@Linkgoron
Linkgoronforce-pushed the stream-finished-abort-signal branch from b330729 to caa5a1bCompareFebruary 13, 2021 14:57
Comment threadlib/internal/streams/end-of-stream.js Outdated
Comment threadtest/parallel/test-stream-finished.js Outdated
Comment threadtest/parallel/test-stream-finished.js Outdated
Comment threadlib/internal/streams/end-of-stream.js Outdated
Comment threadtest/parallel/test-stream-finished.js Outdated
@Linkgoron
Linkgoronforce-pushed the stream-finished-abort-signal branch from caa5a1b to 3ca500aCompareFebruary 13, 2021 17:43
@benjamingr

Copy link
Copy Markdown
Member

@nodejs/streams

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

I'm not convinced by this change - I might expect for the stream to be destroyed on abort. What's the rationale for not doing so?

@Linkgoron

Linkgoron commented Feb 15, 2021

Copy link
Copy Markdown
ContributorAuthor

IMO finished is more of a passive listener than a stream controller. It doesn't really do anything except add listeners on the underlying stream (It's also in the description A function to get notified when a stream is no longer readable, writable or has experienced an error or a premature close event). The cleanup function that (already) returns from finished also doesn't destroy the underlying stream.

However, maybe aborting should invoke the cleanup function (which it currently doesn't).

@mcollina

Copy link
Copy Markdown
Member

If finished does not destroy the stream, then pipeline will?

@ronag

ronag commented Feb 17, 2021

Copy link
Copy Markdown
Member

If finished does not destroy the stream, then pipeline will?

Yes. The way I see it pipeline has "non recoverable side effects" on the stream and should destroy while finished has no side effects and should not destroy.

@Linkgoron
Linkgoronforce-pushed the stream-finished-abort-signal branch from 3ca500a to e027154CompareFebruary 17, 2021 15:58
Comment threadlib/internal/streams/end-of-stream.js Outdated
@Linkgoron
Linkgoronforce-pushed the stream-finished-abort-signal branch 2 times, most recently from 44bd8c6 to 7938420CompareFebruary 17, 2021 20:11

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

lgtm

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@Linkgoron

Copy link
Copy Markdown
ContributorAuthor

Is there anything else that I need to do here to get this merged?

@aduh95aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Feb 25, 2021
@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

@nodejs-github-bot

Copy link
Copy Markdown
Collaborator

PR-URL: nodejs#37354
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@aduh95
aduh95force-pushed the stream-finished-abort-signal branch from 7938420 to 7837d3fCompareFebruary 26, 2021 10:21
@aduh95
aduh95 merged commit 7837d3f into nodejs:masterFeb 26, 2021
@aduh95

Copy link
Copy Markdown
Contributor

Landed in 7837d3f

@Linkgoron
Linkgoron deleted the stream-finished-abort-signal branch February 26, 2021 14:28
targos pushed a commit that referenced this pull request Feb 28, 2021
PR-URL: #37354
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
@targostargos mentioned this pull request Mar 2, 2021
@targostargos added the semver-minor PRs that contain new features and should be released in the next minor version. label May 27, 2021
nodejs-github-bot pushed a commit that referenced this pull request Feb 2, 2023
Refs: #46205
PR-URL: #46403
Refs: #37354
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
MylesBorins pushed a commit that referenced this pull request Feb 18, 2023
Refs: #46205
PR-URL: #46403
Refs: #37354
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
debadree25 added a commit to debadree25/node that referenced this pull request Feb 27, 2023
Refs: nodejs#46205
PR-URL: nodejs#46403
Refs: nodejs#37354
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
danielleadams pushed a commit that referenced this pull request Apr 11, 2023
Refs: #46205
PR-URL: #46403
Refs: #37354
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Robert Nagy <ronagy@icloud.com>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.semver-minorPRs that contain new features and should be released in the next minor version.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants

@Linkgoron@benjamingr@mcollina@ronag@nodejs-github-bot@aduh95@jasnell@targos