JavaScript Medium technical 1 views 2 min read

How does Promise.allSettled() differ from Promise.all()?

Peer-reviewed by HireXTech Technical Panel Updated for 2025/2026 hiring Editorial standards
Practise this track
Interviewer Expectations for this Question
01
Core Competency

Assesses fundamental understanding of JavaScript conventions, runtime behavior, and memory/performance considerations.

02
Evaluation Criteria

Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.

Comprehensive Model Answer Verified Solution

Promise.allSettled() and Promise.all() both handle multiple promises, but they behave differently when promises are rejected.

Promise.all() - fails fast:

     const promises = [
       Promise.resolve(1),
       Promise.reject('Error'),
       Promise.resolve(3)
     ];

     Promise.all(promises)
       .then(results => console.log(results))
       .catch(error => console.log(error)); // 'Error'
     // Stops at first rejection
     

Promise.allSettled() - waits for all:

     Promise.allSettled(promises)
       .then(results => console.log(results));
     /*
     [
       { status: 'fulfilled', value: 1 },
       { status: 'rejected', reason: 'Error' },
       { status: 'fulfilled', value: 3 }
     ]
     */
     

Practical example - multiple API calls:

     async function fetchUserData(userId) {
       const endpoints = [
         fetch(`/api/users/${userId}`),
         fetch(`/api/users/${userId}/posts`),
         fetch(`/api/users/${userId}/comments`)
       ];

       const results = await Promise.allSettled(endpoints);

       return {
         profile: results[0].status === 'fulfilled' 
           ? await results[0].value.json() 
           : null,
         posts: results[1].status === 'fulfilled' 
           ? await results[1].value.json() 
           : [],
         comments: results[2].status === 'fulfilled' 
           ? await results[2].value.json() 
           : []
       };
     }
     

Filtering settled results:

     const results = await Promise.allSettled(promises);

     const successful = results
       .filter(r => r.status === 'fulfilled')
       .map(r => r.value);

     const failed = results
       .filter(r => r.status === 'rejected')
       .map(r => r.reason);

     console.log(`${successful.length} succeeded, ${failed.length} failed`);
     

When to use each:

| Use Promise.all() when: | Use Promise.allSettled() when: |
|------------------------|-------------------------------|
| All promises must succeed | You need all results regardless of status |
| Failure should stop execution | You want to handle each result independently |
| You want to fail fast | You need a complete report |

Candidate Response Strategy & Interview Tips

  1. Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
  2. Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
  3. Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
  4. Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.
Related Topics & Skills
Spotted an error or have an alternative solution?