For tests purposes, even though I voluntarily inject javascript syntax errors in my nodejs project, pm2 still manage to start the app I have created.
Syntax errors are properly logged, I can see them, but the command pm2 list
still returns the app with a status set to "online"
Does it make sense that pm2 can start an app even though there are syntax errors in it?
What are the cases when pm2 returns an app status as "errored" when using pm2 list
?
If you catch the error it will be logged by PM2, but the service itself won't stop / restart.
These uncaughtExceptions are not Syntax Errors, but are errors which are only detected at runtime, for example accessing a method on an object which is not present, or trying to access a variable which has not been declared.
process.on('uncaughtException', (err) => {
console.log('uncaughtException');
console.log(err);
});