Hacker News new | ask | show | jobs
by moring 946 days ago
This doesn't solve the issue at all, does it? If Promise.all() is never reached, neither is Promise.allSettled().
2 comments

allSettled() returns an array of objects for each promise result that tells you if it has been rejected or resolved, so as long as all the promises reject or resolve then it should solve the problem I think?
moring is describing an issue where the creation of the promise itself fails, which means Promise.all/Promise.allSettled is never called.
Use the second pattern with `.allSettled` but map it with an async function.

      const result = await Promise.allSettled(elements.map(async x => someAsyncFunction3(computeArg3(x))));
Yes, it works fine. As mentioned below just pass an asynchronous function and it’ll catch it.