Skip to content
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

Report unhandled Promise rejections #6939

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/server/pid/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,5 +47,9 @@ module.exports = Promise.method(function (kbnServer, server, config) {
// resend SIGINT
process.kill(process.pid, 'SIGINT');
});

process.on('unhandledRejection', function (reason, promise) {
server.log(['warning'], `Detected an unhandled Promise rejection.\n${reason}`);
});
});
});
21 changes: 10 additions & 11 deletions src/ui/public/notify/notify.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,19 @@ if (!!kbnIndex) {
});
}

/**
* Global Angular exception handler (NOT JUST UNCAUGHT EXCEPTIONS)
*/
// modules
// .get('exceptionOverride')
// .factory('$exceptionHandler', function () {
// return function (exception, cause) {
// rootNotifier.fatal(exception, cause);
// };
// });

window.onerror = function (err, url, line) {
rootNotifier.fatal(new Error(err + ' (' + url + ':' + line + ')'));
return true;
};

if (window.addEventListener) {
const notify = new Notifier({
location: 'Promise'
});

window.addEventListener('unhandledrejection', function (e) {
notify.log(`Detected an unhandled Promise rejection.\n${e.reason}`);
});
}

export default rootNotifier;