Skip to content

Commit

Permalink
avoid unexpected unhandledRejection
Browse files Browse the repository at this point in the history
  • Loading branch information
suguru03 committed Aug 2, 2017
1 parent 4f90934 commit 872c254
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/debuggability.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,12 @@ Promise.prototype.suppressUnhandledRejections = function() {
};

Promise.prototype._ensurePossibleRejectionHandled = function () {
if ((this._bitField & IS_REJECTION_IGNORED) !== 0) return;
this._setRejectionIsUnhandled();
async.invokeLater(this._notifyUnhandledRejection, this, undefined);
var promise = this;
if ((promise._bitField & IS_REJECTION_IGNORED) !== 0) return;
promise._setRejectionIsUnhandled();
async.throwLater(function() {
promise._notifyUnhandledRejection();
}, undefined);
};

Promise.prototype._notifyUnhandledRejectionIsHandled = function () {
Expand Down

0 comments on commit 872c254

Please sign in to comment.