Closed
Description
Nodejs version 6.10.x
I have this:
const file = path.resolve(__dirname + '/foo.js');
const n = cp.spawn(file, []); // EACCES error is thrown here
n.once('error', function () {
// this does not get hit !!
});
so it seems like I should do this instead (but the try/catch seems unfortunate):
let n;
try{
n = cp.spawn(file, []); // EACCES error is thrown here
}
catch(err){
return cb(err);
}
n.once('error', function () {
// this does not get hit !!
});
seems like the 'error' handler should be given the chance to capture error, instead of necessitating a try/catch, am I doing something wrong?
Perhaps because Node core does not even create the n
child process object, that seems like an implementation "mistake".
HOW TO REPLICATE:
Create a file without executable permissions, then try to execute it directly:
#!/usr/bin/env bash
touch my-non-executable-file.js
./my-non-executable-file.js
so that would be something like:
const k = cp.spawn('/foo/bar/my-non-executable-file.js');
the above should throw an error, instead of using k.on('error', fn)
Metadata
Metadata
Assignees
Labels
No labels