★ wanayoo — archive 1999 https://github.com/nodejs/node/pull/32373Nouvelle recherche | Portail wanayoo
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
Closed

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 Mar 19, 2020
@ronag ronag added the stream label Mar 19, 2020
@ronag
Copy link
Member Author

@ronag 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 ronag commented Mar 19, 2020

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

@BridgeAR BridgeAR Mar 19, 2020

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

@ronag ronag Mar 19, 2020

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

@ronag ronag Mar 19, 2020

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 label Mar 19, 2020
@ronag ronag removed the wip label Mar 19, 2020
@mcollina
Copy link
Member

@mcollina mcollina commented Mar 20, 2020

What is the performance cost that you are mentioning?

@ronag
Copy link
Member Author

@ronag 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 label Mar 20, 2020
@ronag
Copy link
Member Author

@ronag 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 label Mar 20, 2020
Copy link
Member

@mcollina mcollina left a comment

lgtm

@ronag ronag removed blocked wip labels Apr 5, 2020
@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Apr 5, 2020

@nodejs-github-bot
Copy link
Contributor

@nodejs-github-bot nodejs-github-bot commented Apr 5, 2020

@ronag
Copy link
Member Author

@ronag ronag commented Apr 6, 2020

@vweevers
Copy link
Contributor

@vweevers 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 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 hidden.

@vweevers
Copy link
Contributor

@vweevers 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
Contributor

@nodejs-github-bot nodejs-github-bot commented Apr 6, 2020

@ronag
Copy link
Member Author

@ronag ronag commented Apr 6, 2020

@mcollina @addaleax PTAL, made test compatible with Windows

Copy link
Member

@addaleax addaleax left a comment

Still LGTM

ronag added a commit that referenced this issue 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 ronag commented Apr 6, 2020

Landed in 98b6b2d

@ronag ronag closed this Apr 6, 2020
BethGriggs pushed a commit that referenced this issue 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 added a commit that referenced this issue 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>
@targos targos added the backport-blocked-v12.x label Apr 22, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport-blocked-v12.x stream
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

8 participants