Better alternatives to uncaughtException handler for async code

40 views
Skip to first unread message

Matthew Browne

unread,
May 30, 2014, 10:05:03 AM5/30/14
to nod...@googlegroups.com
I thought this was an informative thread:
Why throw exceptions in async code?

There's a relatively new node.js feature that I think helps with this issue:
http://nodejs.org/api/domain.html

As it says there, "Domain error handlers are not a substitute for closing down your process when an error occurs", but by using it in conjunction with the cluster module, it seems you can rest assured that your whole server won't crash if an error isn't caught, without the problems involved with trying to keep your process running after process.on('uncaughtException', ...)

'By the very nature of how throw works in JavaScript, there is almost never any way to safely "pick up where you left off", without leaking references, or creating some other sort of undefined brittle state.'

I haven't tried this out yet but it sounds like the way to go for production apps...is this now the recommended best practice?

Thanks,
Matt
Reply all
Reply to author
Forward
0 new messages