ShaharAmir
← Back to Blog
JavaScript1 min read

Promise.all vs Promise.allSettled

Know when to use each - one fails fast, the other waits for everything

S
Shahar Amir

The Difference

Promise.all fails immediately when ANY promise rejects. Promise.allSettled waits for ALL promises, regardless of outcome.

Promise.all - Fail Fast

javascript
12345678
const results = await Promise.all([
fetch('/api/users'),
fetch('/api/posts'),
fetch('/api/comments')
]);
// If ANY request fails, the whole thing rejects
// You lose the successful responses too!

Promise.allSettled - Get Everything

javascript
12345678910111213
const results = await Promise.allSettled([
fetch('/api/users'),
fetch('/api/posts'),
fetch('/api/comments')
]);
results.forEach(result => {
if (result.status === 'fulfilled') {
console.log('Success:', result.value);
} else {
console.log('Failed:', result.reason);
}
});

When to Use Each

Use Promise.all when:

  • All promises MUST succeed
  • One failure means you can't continue
  • Example: Loading required page data

Use Promise.allSettled when:

  • You want partial results
  • Failures shouldn't block successes
  • Example: Sending notifications to multiple users

Pro Tip

javascript
1234
// Extract only successful results
const successful = results
.filter(r => r.status === 'fulfilled')
.map(r => r.value);

#promises#async#comparison#fundamentals

Stay Updated 📬

Get the latest tips and tutorials delivered to your inbox. No spam, unsubscribe anytime.