I'm using childprocess.execFile to run a phantomjs script with the code below, and everything is fine when it runs successfully but if there is an error in the script the callback is never called ("child process finished" doesn't show in the logs).
How should this situation be handled? My app needs to know if the child process has failed
childProcess.execFile(binPath, childArgs, function(err, stdout, stderr) {
console.log('child process finished');
console.log(stdout);
console.log(err);
console.log(stderr);
res.json({'status':'finished'});
// handle results
})