- Promise.all() — waits for ALL to resolve. Rejects immediately if ANY rejects. Use when all must succeed.
- Promise.allSettled() — waits for ALL to settle (resolve OR reject). Never rejects itself. Use when you need all results regardless of failure.
- Promise.race() — settles with the FIRST settled promise (resolve or reject). Use for timeout patterns.
- Promise.any() — resolves with the FIRST resolved promise. Rejects only if ALL reject. Use for fallback/redundancy.
const fast = fetch('/fast'); // 100ms
const slow = fetch('/slow'); // 500ms
const bad = fetch('/broken'); // 200ms, rejects
await Promise.all([fast, slow]); // ✅ 500ms (waits for both)
await Promise.all([fast, bad]); // ❌ rejects at 200ms
const results = await Promise.allSettled([fast, slow, bad]);
// [{status:'fulfilled', value:...}, ..., {status:'rejected', reason:...}]
await Promise.race([fast, slow]); // resolves at 100ms with fast result
await Promise.any([bad, fast]); // resolves at 100ms (ignores bad)
// Timeout pattern with race:
const withTimeout = (p, ms) => Promise.race([
p,
new Promise((_, r) => setTimeout(() => r(new Error('Timeout')), ms))
]);
💡 allSettled is your safety net — it always resolves, making it great for "fire multiple requests, report all results" patterns.