Skip to content

Commit

Permalink
Fix #1501 #1502
Browse files Browse the repository at this point in the history
  • Loading branch information
petkaantonov committed May 25, 2019
1 parent c54bac1 commit c9618f0
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/reduce.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,13 @@ ReductionPromiseArray.prototype._iterate = function (values) {

this._currentCancellable = value;

for (var j = i; j < length; ++j) {
var maybePromise = values[j];
if (maybePromise instanceof Promise) {
maybePromise.suppressUnhandledRejections();
}
}

if (!value.isRejected()) {
for (; i < length; ++i) {
var ctx = {
Expand Down
28 changes: 28 additions & 0 deletions test/mocha/unhandled_rejections.js
Original file line number Diff line number Diff line change
Expand Up @@ -782,3 +782,31 @@ if (asyncAwaitSupported) {
});
});
}

describe("issues", function () {
setupCleanUps();

specify("GH-1501-1", function testFunction() {
var ret = onUnhandledFail(testFunction);
Promise.reduce([Promise.resolve("foo"), Promise.reject(new Error("reason"), Promise.resolve("bar"))],
function() {},
{}).caught(function() {});
return ret;
});

specify("GH-1501-2", function testFunction() {
var ret = onUnhandledFail(testFunction);
Promise.reduce([Promise.delay(100), Promise.reject(new Error("reason"))],
function() {},
{}).caught(function() {});
return ret;
});

specify("GH-1501-3", function testFunction() {
var ret = onUnhandledFail(testFunction);
Promise.reduce([Promise.reject(new Error("reason"))],
function() {},
Promise.reject(new Error("reason2"))).caught(function() {});
return ret;
});
})

0 comments on commit c9618f0

Please sign in to comment.