diff --git a/src/reduce.js b/src/reduce.js index a77e7415c..57da37c26 100644 --- a/src/reduce.js +++ b/src/reduce.js @@ -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 = { diff --git a/test/mocha/unhandled_rejections.js b/test/mocha/unhandled_rejections.js index b4a43ece7..542788a20 100644 --- a/test/mocha/unhandled_rejections.js +++ b/test/mocha/unhandled_rejections.js @@ -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; + }); +})