-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
No error was thrown when spawn command was existed but non-executable #26852
Comments
IMO going from a throw to an emitted error is a good thing, since Let me show what I think is a real bug in Node.js. With this script located in 'use strict';
const { spawn } = require('child_process');
const { existsSync } = require('fs');
const { resolve } = require('path');
function test(path) {
const exists = existsSync(path);
const child = spawn(path);
const hasStdin = !!child.stdin;
child.on('error', (e) => {
console.log(`Path: "${path}".\nExists: ${exists}.\nHas stdin: ${hasStdin}\n\n`);
});
}
test('x');
test('/tmp/child_process/x');
test('./x');
test('y');
test('/tmp/child_process/y');
test('./y');
We have a clear inconsistency. If the file does not exist, the object returned by /cc @nodejs/child_process |
@bnoordhuis What do you think? |
The behavior change comes from #19294, which began classifying
I think this is more about the error that's occurring. The two cases where "has stdin" is
We can:
|
Actually, on second thought, we probably do want to setup stdio to prevent situations like nodejs/help#1769. |
having |
As more spawn() errors are classified as runtime errors, it's no longer appropriate to only check UV_ENOENT when determining if stdio can be setup. This commit reverses the check to look for EMFILE and ENFILE specifically. PR-URL: nodejs#27696 Fixes: nodejs#26852 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
As more spawn() errors are classified as runtime errors, it's no longer appropriate to only check UV_ENOENT when determining if stdio can be setup. This commit reverses the check to look for EMFILE and ENFILE specifically. PR-URL: #27696 Fixes: #26852 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
10.2.0/11.12.0
Darwin localhost 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64
Suppose we have following test script and file
notexe
exist in the same folder. Butnotexe
has no executable permission.So, why did Node 10+ change spawn behaviors? On purpose or regressions?
The text was updated successfully, but these errors were encountered: