Skip to content

Commit

Permalink
Merge branch 'master' into issue-158/pagination
Browse files Browse the repository at this point in the history
  • Loading branch information
jinpingh authored Jun 20, 2019
2 parents 21bd5b8 + 1d3143c commit d54c3f9
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Changelog

in development
--------------
* Exit hubot on unhandled promise rejections and uncaught exceptions, usually caused by unrecoverable errors (bug fix)

0.9.4
-----
Expand Down
23 changes: 23 additions & 0 deletions scripts/stackstorm.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,29 @@ var TWOFACTOR_MESSAGE = "This action requires two-factor auth! Waiting for your
module.exports = function(robot) {
slack_monkey_patch.patchSendMessage(robot);

// Makes the script crash on unhandled rejections instead of ignoring them and keep running.
// Usually happens when trying to connect to a nonexistent instances or similar unrecoverable issues.
// In the future Node.js versions, promise rejections that are not handled will terminate the process with a non-zero exit code.
process.on('unhandledRejection', function(err) {
throw err;
});

// Handle uncaught exceptions, log error and terminate hubot if one occurs
robot.error(function(err, res) {
if (err) {
robot.logger.error(err.stack || JSON.stringify(err));
}
if (res) {
res.send(JSON.stringify({
"status": "failed",
"msg": "An error occurred trying to post the message:\n" + err
}));
}

robot.logger.info('Hubot will shut down ...');
robot.shutdown();
});

var self = this;

var promise = Promise.resolve();
Expand Down

0 comments on commit d54c3f9

Please sign in to comment.