Promise.race settles on the first result including a rejection, and Promise.any waits for the first success.
// race: a fast failure wins, and the slow success is lost
await Promise.race([mirrorA(), mirrorB()])
// any: the first SUCCESS wins
await Promise.any([mirrorA(), mirrorB()])
// all rejected → AggregateError, with .errors
try {
await Promise.any(mirrors)
} catch (e) {
console.log(e.errors) // every rejection reason
}
race is right for a timeout, where a rejection genuinely should win, and any is right for redundancy. The AggregateError is the piece worth knowing about, because a normal catch block logging e.message gets “All promises were rejected” and none of the actual reasons — the reasons are on e.errors and are usually the only useful thing in the failure.