3 ms·
How do you deal with code where the author forgot to handle all of the failure cases and invoke the callback?
by kevingadd 14y ago
How do you deal with code where the author forgot to handle all of the failure cases and invoke the callback?
- STRML 14y agoTo 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 https://github.com/mattinsler/longjohn) for these sorts of situations; the extra stack trace lines become invaluable.
- jahewson 14y agoFix the code.