Skip to content

Commit c9618f0

Browse files
committedMay 25, 2019
Fix #1501 #1502
1 parent c54bac1 commit c9618f0

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed
 

‎src/reduce.js

+7
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@ ReductionPromiseArray.prototype._iterate = function (values) {
9494

9595
this._currentCancellable = value;
9696

97+
for (var j = i; j < length; ++j) {
98+
var maybePromise = values[j];
99+
if (maybePromise instanceof Promise) {
100+
maybePromise.suppressUnhandledRejections();
101+
}
102+
}
103+
97104
if (!value.isRejected()) {
98105
for (; i < length; ++i) {
99106
var ctx = {

‎test/mocha/unhandled_rejections.js

+28
Original file line numberDiff line numberDiff line change
@@ -782,3 +782,31 @@ if (asyncAwaitSupported) {
782782
});
783783
});
784784
}
785+
786+
describe("issues", function () {
787+
setupCleanUps();
788+
789+
specify("GH-1501-1", function testFunction() {
790+
var ret = onUnhandledFail(testFunction);
791+
Promise.reduce([Promise.resolve("foo"), Promise.reject(new Error("reason"), Promise.resolve("bar"))],
792+
function() {},
793+
{}).caught(function() {});
794+
return ret;
795+
});
796+
797+
specify("GH-1501-2", function testFunction() {
798+
var ret = onUnhandledFail(testFunction);
799+
Promise.reduce([Promise.delay(100), Promise.reject(new Error("reason"))],
800+
function() {},
801+
{}).caught(function() {});
802+
return ret;
803+
});
804+
805+
specify("GH-1501-3", function testFunction() {
806+
var ret = onUnhandledFail(testFunction);
807+
Promise.reduce([Promise.reject(new Error("reason"))],
808+
function() {},
809+
Promise.reject(new Error("reason2"))).caught(function() {});
810+
return ret;
811+
});
812+
})

0 commit comments

Comments
 (0)
Please sign in to comment.