Skip to content

Commit

Permalink
Give better stack traces for Unhandled Promise Rejection warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
watson committed Mar 16, 2020
1 parent 7d12b76 commit c2882e4
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/setup_node_env/exit_on_warning.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,16 @@ if (process.noProcessWarnings !== true) {

process.exit(1);
});

// While the above warning listener would also be called on
// unhandledRejection warnings, we can give a better error message if we
// handle them separately:
process.on('unhandledRejection', function(reason) {
console.error('Unhandled Promise rejection detected:');
console.error();
console.error(reason);
console.error();
console.error('Terminating process...');
process.exit(1);
});
}

0 comments on commit c2882e4

Please sign in to comment.