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

child_process: preserve argument type #7391

Closed
wants to merge 6 commits into from
Closed

Conversation

Trott
Copy link
Member

@Trott Trott commented Jun 23, 2016

Checklist
  • make -j4 test (UNIX) or vcbuild test nosign (Windows) passes
  • a test and/or benchmark is included
  • the commit message follows commit guidelines
Affected core subsystem(s)

child_process

Description of change

A previous fix for a maxBuffer bug resulted in a change to the
argument type for the data event on child.stdin and child.stdout
when using child_process.exec().

This fixes the maxBuffer bug in a way that does not have that side
effect.

Fixes: #7342
Refs: #1901

Alternative to #7381 (which changes the argument type and is arguably semver-major for that reason--being affected by it requires relying on undocumented behavior and using exec() in ways that are better suited to fork() or spawn() which are unaffected by either fix).

@Trott Trott added the child_process Issues and PRs related to the child_process subsystem. label Jun 23, 2016
stdoutLen += chunk.byteLength;
stdoutLen += chunk instanceof Buffer ?
chunk.length :
Buffer.byteLength(chunk, encoding);
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you at least line these two lines up with chunk? Same for the other instance of this below.

Copy link
Member Author

Choose a reason for hiding this comment

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

Aligned.

@Trott Trott force-pushed the benchomatic branch 2 times, most recently from 35485cd to 4c7266b Compare June 25, 2016 00:19
@Trott
Copy link
Member Author

Trott commented Jun 25, 2016

@mscdex
Copy link
Contributor

mscdex commented Jun 25, 2016

Looks like the common.mustCall(..., 2) will have to be changed to just common.mustCall() an "at least twice" check or even better, ensure that each separate callback is called at least once, for the stdout-stderr-data test. Windows seems to be less reliable in its chunking?

@Trott
Copy link
Member Author

Trott commented Jun 25, 2016

@mscdex Whoops, yeah, fixed, I hope, let's try again...

CI: https://ci.nodejs.org/job/node-test-pull-request/3080/

@Trott
Copy link
Member Author

Trott commented Jun 25, 2016

CI looks good. /cc @bnoordhuis @cjihrig

kill();
} else {
_stdout.push(chunk);
if (!encoding)
Copy link
Member

Choose a reason for hiding this comment

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

Can you drop the negation and flip the clauses?

A previous fix for a `maxBuffer` bug resulted in a change to the
argument type for the `data` event on `child.stdin` and `child.stdout`
when using `child_process.exec()`.

This fixes the `maxBuffer` bug in a way that does not have that side
effect.

Fixes: nodejs#7342
Refs: nodejs#1901
@Trott
Copy link
Member Author

Trott commented Jun 27, 2016

CI again, hoping my echo for unicode characters tests work across platforms...

CI: https://ci.nodejs.org/job/node-test-pull-request/3096/

@Trott
Copy link
Member Author

Trott commented Jun 27, 2016

Modified tests for Windows. Let's try again:

CI: https://ci.nodejs.org/job/node-test-pull-request/3097/

@Trott
Copy link
Member Author

Trott commented Jun 27, 2016

That CI is green. Woot.

@bnoordhuis I put quotation marks around process.execPath but I'm pretty sure other characters that could conceivably be in the path may adversely affect at least some platforms (probably at least some of $, backticks, different types of quotation marks and slashes, question marks, asterisk...). Maybe that's OK because those are sufficiently infrequent while spaces are pretty common?

@bnoordhuis
Copy link
Member

LGTM

Maybe that's OK because those are sufficiently infrequent while spaces are pretty common?

I agree.

@Trott
Copy link
Member Author

Trott commented Jun 28, 2016

/cc @cjihrig @JacksonTian

@Trott
Copy link
Member Author

Trott commented Jun 29, 2016

I'll land this in 24 hours if no one objects. An additional LGTM or two would be nice, though. /cc @nodejs/collaborators

@Trott Trott closed this Jun 30, 2016
Fishrock123 pushed a commit that referenced this pull request Jul 5, 2016
This reverts commit c9a5990.

PR-URL: #7391
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
Fishrock123 pushed a commit that referenced this pull request Jul 5, 2016
A previous fix for a `maxBuffer` bug resulted in a change to the
argument type for the `data` event on `child.stdin` and `child.stdout`
when using `child_process.exec()`.

This fixes the `maxBuffer` bug in a way that does not have that side
effect.

PR-URL: #7391
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
Fixes: #7342
Refs: #1901
@Fishrock123 Fishrock123 mentioned this pull request Jul 5, 2016
@MylesBorins
Copy link
Contributor

@Trott lts?

@Trott
Copy link
Member Author

Trott commented Jul 12, 2016

@thealphanerd Yes if #6764 lands on LTS, otherwise no.

@MylesBorins
Copy link
Contributor

I've gone ahead and landed this as #6764 landed. Do you think we would be better without either of these changes? Is there any chance of a regression?

MylesBorins pushed a commit that referenced this pull request Jul 12, 2016
This reverts commit c9a5990.

PR-URL: #7391
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jul 12, 2016
A previous fix for a `maxBuffer` bug resulted in a change to the
argument type for the `data` event on `child.stdin` and `child.stdout`
when using `child_process.exec()`.

This fixes the `maxBuffer` bug in a way that does not have that side
effect.

PR-URL: #7391
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
Fixes: #7342
Refs: #1901
@Trott
Copy link
Member Author

Trott commented Jul 12, 2016

@thealphanerd I think we're better off with these changes than without them.

MylesBorins pushed a commit that referenced this pull request Jul 12, 2016
This reverts commit c9a5990.

PR-URL: #7391
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jul 12, 2016
A previous fix for a `maxBuffer` bug resulted in a change to the
argument type for the `data` event on `child.stdin` and `child.stdout`
when using `child_process.exec()`.

This fixes the `maxBuffer` bug in a way that does not have that side
effect.

PR-URL: #7391
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
Fixes: #7342
Refs: #1901
@MylesBorins MylesBorins mentioned this pull request Jul 12, 2016
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
This reverts commit c9a5990.

PR-URL: #7391
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
A previous fix for a `maxBuffer` bug resulted in a change to the
argument type for the `data` event on `child.stdin` and `child.stdout`
when using `child_process.exec()`.

This fixes the `maxBuffer` bug in a way that does not have that side
effect.

PR-URL: #7391
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
Fixes: #7342
Refs: #1901
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
This reverts commit c9a5990.

PR-URL: #7391
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
MylesBorins pushed a commit that referenced this pull request Jul 14, 2016
A previous fix for a `maxBuffer` bug resulted in a change to the
argument type for the `data` event on `child.stdin` and `child.stdout`
when using `child_process.exec()`.

This fixes the `maxBuffer` bug in a way that does not have that side
effect.

PR-URL: #7391
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: Jackson Tian <shyvo1987@gmail.com>
Fixes: #7342
Refs: #1901
@Trott Trott deleted the benchomatic branch January 13, 2022 22:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Encoding of child_process.exec.stdout changed from String to Buffer in v6.2.1
5 participants