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: complete pipeline with stdio #32373

Closed
wants to merge 13 commits into from

Conversation

ronag
Copy link
Member

@ronag ronag commented Mar 19, 2020

stdio (stderr & stdout) should for compatibility
reasons not be closed/end():ed. However, this
causes pipeline with a stdio destination to
never finish. This commit fixes this issue at
a performance cost.

Refs: #7606

Fixes: #32363

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

stdio (stderr & stdout) should for compatibility
reasons not be closed/end():ed. However, this
causes pipeline with a stdio destination to
never finish. This commit fixes this issue at
a performance cost.

Refs: nodejs#7606

Fixes: nodejs#32363
@ronag ronag requested a review from mcollina March 19, 2020 21:41
@ronag ronag added the stream Issues and PRs related to the stream subsystem. label Mar 19, 2020
@ronag
Copy link
Member Author

ronag commented Mar 19, 2020

I'm not sure I understand/agree with not calling end() on stdio streams. However, this PR resolves the issue of pipeline not completing at a performance cost. This is the best solution I've found so far...

@ronag
Copy link
Member Author

ronag commented Mar 19, 2020

@vweevers

err ? reject(err) : resolve();
});
})
]);
Copy link
Member

Choose a reason for hiding this comment

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

It is likely faster to use the callbacks and manually handle everything. It could be wrapped in a single promise to allow to await the result for simplicity. Alternatively just also handle the finish call separately.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is likely faster to use the callbacks and manually handle everything. It could be wrapped in a single promise to allow to await the result for simplicity

Yes, but that makes the implementation more complicated... at least as far as I can determine.

Copy link
Member Author

Choose a reason for hiding this comment

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

@BridgeAR PTAL

@ronag ronag added the wip Issues and PRs that are still a work in progress. label Mar 19, 2020
@ronag ronag removed the wip Issues and PRs that are still a work in progress. label Mar 19, 2020
@mcollina
Copy link
Member

What is the performance cost that you are mentioning?

@ronag
Copy link
Member Author

ronag commented Mar 20, 2020

New information from @vweevers which might make this PR outdated.

Ah, my understanding of it was outdated. Since node v10.12.0 (see #23053 and ERR_STDOUT_CLOSE) you can indeed close these streams. Before they used to throw an error, now they allow it but "secretly" don't close the underlying fd.

@ronag ronag added the wip Issues and PRs that are still a work in progress. label Mar 20, 2020
@ronag
Copy link
Member Author

ronag commented Mar 20, 2020

I'm putting this as blocked until we have gotten further clarification in the issue:

#32363

@ronag ronag added the blocked PRs that are blocked by other issues or PRs. label Mar 20, 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.

lgtm

@ronag ronag removed blocked PRs that are blocked by other issues or PRs. wip Issues and PRs that are still a work in progress. labels Apr 5, 2020
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@ronag
Copy link
Member Author

ronag commented Apr 6, 2020

@vweevers
Copy link
Contributor

vweevers commented Apr 6, 2020

AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
+ actual - expected

+ '"hello" \r\n'
- 'hello\n'

@ronag That's the behavior of echo "hello" on Windows, you'd get the same result with echo "hello" > test. I suggest removing the double quotes and trimming the result.

@ronag
Copy link
Member Author

ronag commented Apr 6, 2020

@ronag That's the behavior of echo "hello" on Windows, you'd get the same result with echo "hello" > test. I suggest removing the double quotes and trimming the result.

So we expect different results on different platforms?

I suggest removing the double quotes and trimming the result.

I don't think that's enough, note the extra space and \r.

@nodejs-github-bot

This comment has been minimized.

@vweevers
Copy link
Contributor

vweevers commented Apr 6, 2020

The default newline on windows is \r\n. The extra space is because echo foo > test adds a space but echo foo> test does not. There are ways around this but normalizing such shell behaviors would not make this node.js test more meaningful.

@nodejs nodejs deleted a comment from nodejs-github-bot Apr 6, 2020
@nodejs nodejs deleted a comment from nodejs-github-bot Apr 6, 2020
@nodejs-github-bot
Copy link
Collaborator

@ronag
Copy link
Member Author

ronag commented Apr 6, 2020

@mcollina @addaleax PTAL, made test compatible with Windows

Copy link
Member

@addaleax addaleax left a comment

Choose a reason for hiding this comment

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

Still LGTM

ronag added a commit that referenced this pull request Apr 6, 2020
stdio (stderr & stdout) should for compatibility
reasons not be closed/end():ed. However, this
causes pipeline with a stdio destination to
never finish. This commit fixes this issue at
a performance cost.

Refs: #7606

Fixes: #32363

PR-URL: #32373
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
@ronag
Copy link
Member Author

ronag commented Apr 6, 2020

Landed in 98b6b2d

@ronag ronag closed this Apr 6, 2020
BethGriggs pushed a commit that referenced this pull request Apr 7, 2020
stdio (stderr & stdout) should for compatibility
reasons not be closed/end():ed. However, this
causes pipeline with a stdio destination to
never finish. This commit fixes this issue at
a performance cost.

Refs: #7606

Fixes: #32363

PR-URL: #32373
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
targos pushed a commit that referenced this pull request Apr 12, 2020
stdio (stderr & stdout) should for compatibility
reasons not be closed/end():ed. However, this
causes pipeline with a stdio destination to
never finish. This commit fixes this issue at
a performance cost.

Refs: #7606

Fixes: #32363

PR-URL: #32373
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stream Issues and PRs related to the stream subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Different behavior between transform function and async generator using pipelines
8 participants