I can't get why a simple node process failing doesn't get detected by pm2.
pm2-dev app.js (or pm2 start app.js) with app.js containing :
throw new Error("test");
=> pm2 does not detect any error and consider the pm2 as "active" when I pm2 status or pm2 list
import "non-existing-file.js";
=> pm2 does not detect any error and consider the pm2 as "active" when I pm2 status or pm2 list
process.exit(1);
=> pm2 detect the error and consider the pm2 in error
Is it normal that the first 2 cases are not detected ? I tried playing with uncaughtException handler but of course failed ...
The goal : I don't want pm2 to consider my app as "alive" if my deployment somehow outputed a broken build (with js import errors for example)
Thanks
throw new Error("test")- this is not reproducible, process status is "stopped" or "errored".import "non-existing-file.js"- this is reproducible, could be specific to node module loader, but then the existing answer applies, you can use a single try...catch on import('app.js') for the whole app