child_process: check execFile and fork args - #2667
Conversation
There was a problem hiding this comment.
Can these be broken into separate const and let variables.
There was a problem hiding this comment.
Yes. I'd prefer that actually. Just literally pulled this over straight from what is in v0.12.
|
Ok. @thefourtheye @cjihrig ... nits in the test fixed |
There was a problem hiding this comment.
Is it possible that both of these fail? If neither is supposed to then mind adding a final else with something like throw new Error('UNREACHABLE'); or the like?
There was a problem hiding this comment.
Well, the fall through on this particular one is required for the next check. Overall, the currently behavior in v0.12 (and this port of that code) is really just a half measure. We're not actually doing a complete check. For instance, execFile('ls',{a:1},'test') goes through without a throw even tho a string is passed in for the callback. Internally, execFile just acts as if the callback wasn't provided at all. Likewise, execFile('ls',[], 'test', function() {}) does not throw either. Nor does execFile('ls',[],'test','test'). The only type that is actually checked is the args, so that if you pass in execFile('ls', 'test'), a TypeError will throw.
Given that this is exactly how it behaves in v0.12 currently (for better or worse), I'd be more inclined to land it as is so we can close the convergence loop first, then make additional improvements separately.
There was a problem hiding this comment.
Thanks for the explanation. Sounds like a good plan. Maybe put a todo comment in the code, or we can open an issue for what you've explained and land the fix in a future master. From how you've described it, there is ambiguity with argument parsing.
There was a problem hiding this comment.
Can we pull the common pos < arguments.length check outside?
There was a problem hiding this comment.
not sure it's worth it to add the nested conditional. performance-wise there's no measurable gain.
so basically, I don't think it's necessary but I'm also not opposed to the change.
There was a problem hiding this comment.
Right, but it will improve the readability and reduce redundant checks. It's just a suggestion I am okay without that as well.
There was a problem hiding this comment.
Given that we'll need to revisit this anyway later. Let's leave it as is
for now and do any additional cleanups in the next round.
On Sep 2, 2015 10:29 PM, "thefourtheye" notifications@github.com wrote:
In lib/child_process.js
#2667 (comment):@@ -118,18 +120,26 @@ exports.execFile = function(file /, args, options, callback/) {
env: null
};
- // Parse the parameters.
- // Parse the optional positional parameters.
- var pos = 1;
- if (pos < arguments.length && Array.isArray(arguments[pos])) {
- args = arguments[pos++];
- } else if (pos < arguments.length && arguments[pos] == null) {
- pos++;
- }
Right, but it will improve the readability and reduce redundant checks.
It's just a suggestion I am okay without that as well.—
Reply to this email directly or view it on GitHub
https://github.com/nodejs/node/pull/2667/files#r38614155.
There was a problem hiding this comment.
Cool. Since we introduced new exception, this would be semver-major?
There was a problem hiding this comment.
Technically. But this is already in v0.12 and is part of the convergence work. It will land in master and will be cherry picked to v4.x
|
@jasnell |
Port of joyent/node commits: * nodejs/node-v0.x-archive@e17c5a7 * nodejs/node-v0.x-archive@70dafa7 Pull over test-child-process-spawn-typeerror.js from v0.12, replacing the existing test in master. The new test includes a broader set of tests on the various arg choices and throws.
Fixing multiple style nits in the test pulled over from v0.12.
aa0f2c0 to
7e5710a
Compare
|
Rebased. |
There was a problem hiding this comment.
not seeing this edit as being critical to land this. can do this in the next pass.
There was a problem hiding this comment.
Sure. No problem. We can actually remove the variable and directly attach the even handler.
|
LGTM. But I would prefer waiting till we get one or more of them. Meanwhile let's have a CI run. |
|
Will get a CI run and get this landed in the morning. This is on the short list of must-do's for v4.0.0 so we definitely need to get this landed soon. CI run started here: https://ci.nodejs.org/job/node-test-pull-request/240/ |
|
CI is looking all green except for an unrelated jenkins failure on one of the windows boxes. The arm tests are still running. |
|
@jasnell That windows slave went offline during the build. Can we give it one more try. cc @nodejs/build |
|
Given that the CI will run when I go to land the PR, I'll wait for that. For now, it's off to bed for me. |
|
@jasnell No problem. I'll start one more run when the current one finishes. Night night :-) |
|
LGTM |
|
New test run: https://ci.nodejs.org/job/node-test-pull-request/242/ |
|
Queued up to land. There are four builds lined up before this one so it may take a while. |
|
After consulting with @jasnell , I cancelled the CI run and re-queued it in https://ci.nodejs.org/job/node-accept-pull-request/123/ (pending), so that it has a better chance of succeeding if hopefully #2679 lands first. |
Port of joyent/node commits: * nodejs/node-v0.x-archive@e17c5a7 * nodejs/node-v0.x-archive@70dafa7 Pull over test-child-process-spawn-typeerror.js from v0.12, replacing the existing test in master. The new test includes a broader set of tests on the various arg choices and throws. Reviewed-By: trevnorris - Trevor Norris <trevnorris@nodejs.org> Reviewed-By: cjihrig - Colin Ihrig <cjihrig@gmail.com> Reviewed-By: thefourtheye - Sakthipriyan Vairamani PR-URL: #2667 Fixes: #2515
|
Landed (manually) in 107cbd6 (cc @rvagg @orangemocha ) |
|
@jasnell you missed my email in the commit log :D |
|
Ugh. Sorry about that. That's why we like automated processes! (When they
|
|
No problem :-) Glad that the patch landed at the earliest. |
Port of joyent/node commits:
Pull over test-child-process-spawn-typeerror.js from v0.12, replacing
the existing test in master. The new test includes a broader set of
tests on the various arg choices and throws.
@rvagg @Fishrock123 @trevnorris @nodejs/tsc
See: #2515