Hacker News new | ask | show | jobs
by STRML 4921 days ago
To be honest... since you can't try/catch, you can't do much.

You can catch the exception with something like this:

  process.on('uncaughtException', function (err) {
    console.err("Uncaught exception: " + err);
    console.err("Uncaught exception stack: " + err.stack);
  });
I use the built-in clustering module (implementation is very simple) so a simple worker crash will result in the error being logged & the worker being restarted.

That's about the best you can do, unfortunately. You could always monkey patch the lib if you can figure out where it's crashing.

I recommend Longjohn(https://github.com/mattinsler/longjohn) for these sorts of situations; the extra stack trace lines become invaluable.