-
-
Notifications
You must be signed in to change notification settings - Fork 39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exit hubot on unhandled promise rejections and other unrecoverable errors #172
Conversation
NAK. Hubot already has a way to handle this: https://hubot.github.com/docs/scripting/#error-handling I especially don't like this: setTimeout(process.exit.bind(process, 1), 1000) Don't schedule This is handled properly in #168. Specifically: The We also call that function directly when we detect situations that will trigger errors, eg: Additionally, #168 refactors a lot of the code to be more concise, follow updated conventions, and comes with tests specifically for some of the situation that could throw errors. Besides #168, the only other work that might need to be done regarding the "perpetual waiting" issue is to create integration tests (eg: with BATS, similar to Closing in favor of #168, but if you disagree feel free to reopen and discuss. |
@blag With https://hubot.github.com/docs/scripting/#error-handling you can handle uncaught exceptions on hubot side which would make sense in other situation or even be more cleaner solution in PR like #168. You can look at https://github.com/slackapi/hubot-slack/pull/112/files why having Handling With the approach you guys are following in #169, - it removes some logic around the reloads that original hubot-stackstorm already had in place for self-healing capabilities. It may affect much more than we think. Instead of always exit on every possible error, hubot to exit on any 100% unrecoverable issue (like this one) and our job is to catch different auth errors in a more granular way rather then |
I took another look at this, and I think it is complementary to #168. Let Hubot catch errors, and let this catch unhandled promise rejections. I still don't like how it exits using @armab What do you think about that? Sorry for not trusting you. I'm still learning advanced Javascript, but I should have given this more thought before closing it. |
@blag Sounds good. This would avoid bad practices of calling https://nodejs.org/api/process.html#process_process_exit_code and loosing any unfinished async calls. |
Just included uncaught exceptions handler in this PR which complements handing unhandledRejection events. I've also removed @blag Please take a look. |
One small change to make but looks good to me. |
@blag Thanks for review! |
Addresses some of the cases StackStorm/st2chatops#124 when hubot was hanging on error with no possible recovery.
In the above error seems the important part is reading an error message & research about it:
when promise reporting an error usually happens in some unrecoverable app state.
Adding a global
unhandledRejection
handler that will catch it and exit the bot on error instead of waiting in noop state will solve this and similar future problems when any external library could be spot in unrecoverable errors.Resources
Related #168