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: do not extend result for *Sync() #13601

Merged
merged 1 commit into from
Jun 13, 2017

Conversation

mscdex
Copy link
Contributor

@mscdex mscdex commented Jun 10, 2017

It appears that when the synchronous child_process methods were added, additional information such as user-provided/parsed options, etc. was being copied to the returned object. Not only is this undocumented/unexpected, but it looks like this may have only been done for the purposes of tests (to test normalized/default options for example).

This PR extracts the actual sync spawning into an internal function which can then be monkey-patched as needed by tests.

I have also changed the errors returned by the exec*Sync() methods so that it matches that of the Error object mutation done for the async exec*() methods (e.g. err.result contains the libuv error name for status codes less than 0).

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

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines
Affected core subsystem(s)
  • child_process

@mscdex mscdex added child_process Issues and PRs related to the child_process subsystem. semver-major PRs that contain breaking changes and should be released in the next major version. labels Jun 10, 2017
@nodejs-github-bot nodejs-github-bot added the child_process Issues and PRs related to the child_process subsystem. label Jun 10, 2017
@cjihrig
Copy link
Contributor

cjihrig commented Jun 10, 2017

Not only is this undocumented/unexpected, but it looks like this may have only been done for the purposes of tests (to test normalized/default options for example).

I agree that it is unexpected. It looks like this was the behavior going all the way back to at least 0.12.0. The tests referenced in this PR are all newer than that, so I'm not sure that the two things are related. @bnoordhuis or @sam-github do either of you know why the inputs were originally attached to the output?

@@ -52,16 +53,18 @@ assert.strictEqual(env.stdout.toString().trim(), 'buzz');
const shellFlags = platform === 'win32' ? ['/d', '/s', '/c'] : ['-c'];
Copy link
Contributor

Choose a reason for hiding this comment

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

tiny nit: common.isWindows...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think it really matters much since we're already explicitly passing 'win32' to this function below here.

@mscdex mscdex force-pushed the child_process-no-extend-result branch from a19761a to 14f88fe Compare June 10, 2017 19:44
@mscdex
Copy link
Contributor Author

mscdex commented Jun 10, 2017

Forgot to re-add a removed test. New CI: https://ci.nodejs.org/job/node-test-pull-request/8594/

@mscdex
Copy link
Contributor Author

mscdex commented Jun 12, 2017

/cc @nodejs/ctc

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

@mscdex mscdex force-pushed the child_process-no-extend-result branch from 14f88fe to 1ed6ece Compare June 13, 2017 00:45
@jasnell
Copy link
Member

jasnell commented Jun 13, 2017

@sam-github
Copy link
Contributor

Sorry, I don't know why they were added. Getting rid of them seems like a good idea.

@refack
Copy link
Contributor

refack commented Jun 13, 2017

@jasnell
Copy link
Member

jasnell commented Jun 13, 2017

PR-URL: nodejs#13601
Reviewed-By: Refael Ackermann <refack@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
@mscdex mscdex force-pushed the child_process-no-extend-result branch from 1ed6ece to 448c4c6 Compare June 13, 2017 23:20
@mscdex mscdex merged commit 448c4c6 into nodejs:master Jun 13, 2017
@mscdex mscdex deleted the child_process-no-extend-result branch June 13, 2017 23:22
targos added a commit to targos/node that referenced this pull request Oct 21, 2017
In PR [1], a bunch of properties were removed from the error thrown by
execSync and execFileSync. It turns out that some of those were still
supposed to be there, as the documentation states that the error
contains the entire result from the spawnSync call.

[1] nodejs#13601
targos added a commit that referenced this pull request Oct 23, 2017
In PR [1], a bunch of properties were removed from the error thrown by
execSync and execFileSync. It turns out that some of those were still
supposed to be there, as the documentation states that the error
contains the entire result from the spawnSync call.

[1] #13601

PR-URL: #16060
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
addaleax pushed a commit to ayojs/ayo that referenced this pull request Oct 26, 2017
In PR [1], a bunch of properties were removed from the error thrown by
execSync and execFileSync. It turns out that some of those were still
supposed to be there, as the documentation states that the error
contains the entire result from the spawnSync call.

[1] nodejs/node#13601

PR-URL: nodejs/node#16060
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
addaleax pushed a commit to ayojs/ayo that referenced this pull request Dec 7, 2017
In PR [1], a bunch of properties were removed from the error thrown by
execSync and execFileSync. It turns out that some of those were still
supposed to be there, as the documentation states that the error
contains the entire result from the spawnSync call.

[1] nodejs/node#13601

PR-URL: nodejs/node#16060
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
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. semver-major PRs that contain breaking changes and should be released in the next major version.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants