Skip to content

Commit

Permalink
Fixes #117
Browse files Browse the repository at this point in the history
  • Loading branch information
petkaantonov committed Feb 18, 2014
1 parent 9926365 commit 73afa4a
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/promise.js
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,8 @@ function Promise$_follow(promise) {
promise._getCarriedStackTrace());
}

if (promise._isRejectionUnhandled()) promise._unsetRejectionIsUnhandled();

if (debugging &&
promise._traceParent == null) {
promise._traceParent = this;
Expand Down
30 changes: 30 additions & 0 deletions test/mocha/unhandled_rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,37 @@ describe("immediate failures with .then", function(done) {
});
});

describe("gh-117", function() {
specify("eventually rejected promise", function(done) {
onUnhandledFail();

Promise.resolve().then(function() {
return new Promise(function(_, reject) {
setTimeout(function() {
reject(13);
}, 13);
});
}).caught(async(done));
});

specify("already rejected promise", function(done) {
onUnhandledFail();

Promise.resolve().then(function() {
return Promise.reject(13);
}).caught(async(done));
});

specify("immediately rejected promise", function(done) {
onUnhandledFail();

Promise.resolve().then(function() {
return new Promise(function(_, reject) {
reject(13);
});
}).caught(async(done));
});
});

if (Promise.hasLongStackTraces()) {
describe("Gives long stack traces for non-errors", function() {
Expand Down

0 comments on commit 73afa4a

Please sign in to comment.