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: make finished try to wait for 'close' #32158

Closed
wants to merge 2 commits into from

Conversation

ronag
Copy link
Member

@ronag ronag commented Mar 9, 2020

Pipeline uses eos which will invoke the callback
on 'finish' and 'end' before all streams have been
fully destroyed.

Fixes: #32032

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. blocked PRs that are blocked by other issues or PRs. labels Mar 9, 2020
@ronag
Copy link
Member Author

ronag commented Mar 9, 2020

This is waiting for/blocked by #32051

@ronag ronag force-pushed the pipeline-wait-for-close branch 3 times, most recently from 18c3de4 to c13abc8 Compare March 9, 2020 16:33
@ronag
Copy link
Member Author

ronag commented Mar 10, 2020

@vweevers

@ronag ronag force-pushed the pipeline-wait-for-close branch 2 times, most recently from 747fbf7 to 059b055 Compare March 10, 2020 07:21
@ronag ronag changed the title stream: make pipeline try to wait for 'close' stream: make finished try to wait for 'close' Mar 10, 2020
@ronag ronag force-pushed the pipeline-wait-for-close branch 2 times, most recently from 9725ba8 to 2fc0856 Compare March 10, 2020 10:03
let writableFinished = stream.writableFinished ||
(wState && wState.finished);
const onfinish = () => {
writableFinished = true;
if (willEmitClose && (!stream.readable || readable)) return;
Copy link
Member Author

@ronag ronag Mar 10, 2020

Choose a reason for hiding this comment

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

!stream.readable || readable is for the case where the stream is Duplex, but we might not want to wait for 'end' in which case autoDestroy won't be called and 'close' won't be emitted. An example of this is:

await pipeline(readable, duplex)

For the last argument duplex, pipeline will set readable: false explicitly for eos to indicate this.

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, I'm ok with this.

ronag referenced this pull request Mar 10, 2020
If the last stream in a pipeline is still usable/readable
don't destroy it to allow further composition.

Fixes: #32105

PR-URL: #32110
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
@ronag

This comment has been minimized.

@addaleax
Copy link
Member

@ronag I guess this is no longer blocked now, but needs a rebase?

@ronag ronag added author ready PRs that have at least one approval, no pending requests for changes, and a CI started. and removed blocked PRs that are blocked by other issues or PRs. labels Mar 13, 2020
@addaleax addaleax removed the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Mar 13, 2020
@addaleax
Copy link
Member

@ronag I’m not sure if this is a new conflict, but the Github UI still says that there are some… also, when adding author ready, make sure that the PR has a fresh CI run :)

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@ronag
Copy link
Member Author

ronag commented Mar 23, 2020

needs another @nodejs/tsc approval

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@ronag ronag requested a review from jasnell March 24, 2020 08:49
@ronag
Copy link
Member Author

ronag commented Mar 25, 2020

rebased to fix conflicts

@nodejs-github-bot

This comment has been minimized.

Pipeline uses eos which will invoke the callback
on 'finish' and 'end' before all streams have been
fully destroyed.

Fixes: nodejs#32032
@nodejs-github-bot
Copy link
Collaborator

nodejs-github-bot commented Mar 25, 2020

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

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

@nodejs-github-bot
Copy link
Collaborator

@ronag
Copy link
Member Author

ronag commented Mar 26, 2020

green CI & CITGM, waiting for another @nodejs/tsc approval

addaleax pushed a commit that referenced this pull request Mar 27, 2020
Pipeline uses eos which will invoke the callback
on 'finish' and 'end' before all streams have been
fully destroyed.

Fixes: #32032

PR-URL: #32158
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
@addaleax
Copy link
Member

Landed in 1428a92

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-major PRs that contain breaking changes and should be released in the next major version. stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

finished(stream, cb) invokes callback too early
6 participants