title: PM2 is catching errors before they reach 'uncaught Exception' in Node.js
body: <p><strong>Hey Guys,</strong>
  I am running a discordbot with Discord.js in Node.js. My goal is to run it via pm2 on a Linux Ubuntu Server.</p>
  <p>I want to build a cleanup process <em>before</em> exiting the program on <em>uncaught Exception</em>.</p>
  <p>However when I throw a sample error <em>and</em> run it via pm2 <em>uncaught Exception</em> is not reached, pm2 is just logging the error and continue running the script.
  <strong>When running it directly with Node.js, without pm2 everything works as expected.</strong></p>
  <p>Here is my code:</p>
  <pre><code>process.on('uncaughtException', async (err, origin) =&gt; {
      console.log('test')
      // await Cleanup();
      process.exit(1);
  });
  </code></pre>
  <p>Here the console output running it with pm2:</p>
  <pre><code>Error: Test error
  at Object.execute (script xxxx)
  at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
  at async xxx
  </code></pre>
  <p>As you can see pm2 is kind of preventing the Test error to reach <em>uncaughtException</em>. Pm2 is not restarting the script, and is not logging 'test'</p>
  <p>I also tried catching the error via <em>SIGINT</em> or <em>SIGTERM</em> but none of these are working.</p>
  <p>Is there an option in pm2 to disable this behavior?</p>
  <p><strong>Thanks for any help!</strong></p>