Give better stack traces for Unhandled Promise Rejection warnings (#60235) (#60352)

This commit is contained in:
Thomas Watson 2020-03-17 12:54:47 +01:00 committed by GitHub
parent 994fb9dab7
commit 029d5e50b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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);
});
}