Catching unhandled promise rejection


#1

I’m trying to find a way to catch all unhandled promise rejections to avoid having to specify error handlers or use catch() for every promise since I’m developing a module that uses promises heavily. I found some discussion within a github issue that gave me the impression that the following should work:

 process.on('unhandledRejection', function(promise, reason){
         console.log(promise);
         console.log(reason);
 });

This however doesn’t seem to work, and the dev tools still print out “Uncaught (in promise)” to the console. Am I doing something wrong or is this expected behavior? Thanks


#2

What happens when you try the same in Chrome? I thought (perhaps mistakenly) that native Promises did not have a global unhandledRejection event.


#3

Did you ever figure this out? I’m having the same issue now.