Skip to content

Commit

Permalink
Give better stack traces for Unhandled Promise Rejection warnings (#6…
Browse files Browse the repository at this point in the history
  • Loading branch information
watson committed Mar 17, 2020
1 parent 994fb9d commit 029d5e5
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 029d5e5

Please sign in to comment.