T
T
tuxx2017-09-23 13:19:08
JavaScript
tuxx, 2017-09-23 13:19:08

Catching node.js errors?

For some reason, the program falls off without any errors in the logs. I catch fatal errors and exit events like this:

[
   'exit',
   'SIGINT',
   'SIGTERM',
   'SIGBREAK'
].forEach(event =>
{
   process.on(event, () =>
   {
      Cleanup(event)
   })
})

process.on('uncaughtException\n', err =>
{
   console.error('Неотловленная ошибка', err.message, err.stack)
})

process.on('unhandledRejection\n', (reason, promise) =>
{
   console.error('Ошибка unhandledRejection', reason)
})

But sometimes I just get a message from the Cleanup function that the completion was called and the exit event. exitCode is undefined. Because the program is launched through forever, then this leads to a cyclic restart.
node.js v8.4.0
npm 5.3.0
Debian 7.11

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question