Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Promise.reduce unhandled rejections (#1501) #1502

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/reduce.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,15 @@ ReductionPromiseArray.prototype._iterate = function (values) {

this._currentCancellable = value;

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

if (!value.isRejected()) {
for (; i < length; ++i) {
var ctx = {
Expand Down Expand Up @@ -142,7 +151,7 @@ function reduce(promises, fn, initialValue, _each) {
function gotAccum(accum) {
this.accum = accum;
this.array._gotAccum(accum);
var value = tryConvertToPromise(this.value, this.array._promise);
var value = this.value;
if (value instanceof Promise) {
this.array._currentCancellable = value;
return value._then(gotValue, undefined, undefined, this, undefined);
Expand Down