re: What's wrong with Promise.allSettled() and Promise.any()❓ VIEW POST


allSettled is useful in at least two principle cases. First, when calling multiple operations that are recoverable on failure. Second, calling multiple operations where 'silent' behavior is desired.

It avoids using errors for flow control, which is good.

const [r1, r2] = await Promise.allSettled([op1(), op2()]);

// decode state of the operations and retry if needed //
// or, if one does not care about the results, just invoke it and move on //

I totally agree - this is useful scenario.
My point is that it can be easily achieved with current api without introducing new methods:

const [r1, r2] = await Promise.all([op1(), op2()].map(p => p.catch(e => e)));

// decode state of operations by simply checking "instanceof Error".
code of conduct - report abuse