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: restore exec{File}Sync error props #16060

Closed
wants to merge 2 commits into from

Conversation

targos
Copy link
Member

@targos targos commented Oct 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] #13601

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines
Affected core subsystem(s)

child_process

@nodejs-github-bot nodejs-github-bot added the child_process Issues and PRs related to the child_process subsystem. label Oct 7, 2017
@@ -112,6 +112,8 @@ assert.strictEqual(ret, `${msg}\n`,
// Verify the execFileSync() behavior when the child exits with a non-zero code.
{
const args = ['-e', 'process.exit(1)'];
const spawnSyncResult = spawnSync(process.execPath, args);
const spawnSyncKeys = Object.keys(spawnSyncResult);
Copy link
Member

Choose a reason for hiding this comment

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

Suggestion:

const spawnSyncKeys = Object.keys(spawnSyncResult).sort();
assert.deepStrictEqual(spawnSyncKeys, [ /* ... */ ]);

Right now you check that the corresponding properties exist on the error object but that won't catch regressions where the result of spawnSync() lacks some (or all) properties.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@@ -566,8 +566,7 @@ function checkExecSyncError(ret, args, cmd) {
err = new Error(msg);
}
if (err) {
err.status = ret.status < 0 ? errname(ret.status) : ret.status;
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this logic being lost by moving to Object.assign()?

Copy link
Member Author

@targos targos Oct 21, 2017

Choose a reason for hiding this comment

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

Yes but I don't think this logic should be there. It was also added in #13601.
The documentation says: "The Error object will contain the entire result from child_process.spawnSync()". If we want to translate the status, it should be done in spawnSync and execSync will inherit it.

@targos targos added this to the 9.0.0 milestone Oct 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#13601
@targos
Copy link
Member Author

targos commented Oct 21, 2017

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 <[email protected]>
@targos
Copy link
Member Author

targos commented Oct 23, 2017

Landed in 556ebab

@targos targos closed this Oct 23, 2017
@targos targos deleted the fix-cp-sync branch October 23, 2017 12:43
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 <[email protected]>
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 <[email protected]>
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.

4 participants