Closed marjakh closed 4 years ago
See also https://github.com/tc39/ecma262/issues/1983 for Promise.all
I've updated the README, but given https://github.com/tc39/ecma262/issues/1983#issuecomment-625284399 I'm not sure if there's anything to be done in terms of the description in the spec text. cc @bakkot
I agree. The readme is fine with your clarification, altho imo it doesn't add much, since it seems obvious to me that const o = {}; Promise.any({ [Symbol.iterator]() { throw o; } }).catch((e) => { assert(e === o); })
would hold.
Yea, this is subtle (subtler than other cases where the error cases don't follow what the spec says), but I don't think we should modify the text either.
Text:
This is inaccurate; when an error is thrown while iterating the Promises, we don't reject with an "array of rejection reasons" (meaning AggregateError?), we reject with the individual error.
These "more fundamental failures" occur when:
GetIterator
throws (Promise.any step 3)Get
throws (PerformPromiseAny step 6)IteratorStep
throws (PerformPromiseAny step 8.a-c)IteratorValue
throws (PerformPromiseAny steps 8.e-g)Call(promiseResolve)
throws (PerformPromiseAny step 8.i)Invoke(nextPromise, "then")
throws (PerformPromiseAny step 8.r)The corrsponding text in Promise.all says:
"The all function returns a new promise which is fulfilled with an array of fulfillment values for the passed promises, or rejects with the reason of the first passed promise that rejects. "
This is also not fully accurate, but we can interpret it permissively to mean that the fundamental failures are equal to the rejection of the corresponding Promise which we were iterating when the failure occurred.
However, this kind of permissive interpretation is harder with the text of Promise.any which says explicitly that it rejects with an array of errors.