Nodejs version 6.10.x
I have this:
constfile=path.resolve(__dirname+'/foo.js');constn=cp.spawn(file,[]);// EACCES error is thrown heren.once('error',function(){// this does not get hit !!});so it seems like I should do this instead (but the try/catch seems unfortunate):
letn;try{n=cp.spawn(file,[]);// EACCES error is thrown here}catch(err){returncb(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:
constk=cp.spawn('/foo/bar/my-non-executable-file.js');the above should throw an error, instead of using k.on('error', fn)
Nodejs version
6.10.xI have this:
so it seems like I should do this instead (but the try/catch seems unfortunate):
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
nchild 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.jsso that would be something like:
the above should throw an error, instead of using
k.on('error', fn)