Compare Promise.all, Promise.any, and Promise.allSettled

Quick Overview

Compare JavaScript's Promise.all, Promise.any, and Promise.allSettled across fulfillment, rejection, result shape, input ordering, and empty iterables. Choose among them for independent service calls while accounting for retained errors and the absence of automatic cancellation.

Compare Promise.all, Promise.any, and Promise.allSettled

Company: Micro1

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Online Assessment

## Question Compare JavaScript's `Promise.all`, `Promise.any`, and `Promise.allSettled`. Explain when each aggregate promise fulfills or rejects, what its result preserves, and how you would choose among them for three independent service calls. ### Constraints & Assumptions - Inputs may contain promises or plain values. - Completion order may differ from input order. - A rejected operation may continue running unless it supports external cancellation. - Discuss the empty-iterable case for each method. ### Clarifying Questions to Ask - Does “first” mean first in input order or first to settle? Settlement behavior and result ordering are separate. - Should individual errors be retained? That depends on the method and use case. - Is cancellation automatic after the aggregate settles? No. - Is one successful result enough for the caller? That is the key selection question. ```hint Compare four dimensions For each method, state its success condition, failure condition, returned shape, and ordering guarantee. ``` ### What a Strong Answer Covers - Fail-fast rejection and ordered fulfillment array for `Promise.all`. - First fulfillment and aggregate failure for `Promise.any`. - Wait-for-everything outcome records for `Promise.allSettled`. - Correct empty-input semantics and distinction from `Promise.race`. - Practical choices, error reporting, timeouts, and explicit cancellation. ### Follow-up Questions 1. How would you cancel remaining fetches after `Promise.any` fulfills? 2. How would you require at least two of three operations to succeed? 3. Why do result arrays preserve input order even when completion order differs?

Quick Answer: Compare JavaScript's Promise.all, Promise.any, and Promise.allSettled across fulfillment, rejection, result shape, input ordering, and empty iterables. Choose among them for independent service calls while accounting for retained errors and the absence of automatic cancellation.

|Home/Software Engineering Fundamentals/Micro1
Micro1 logo
Micro1
Aug 9, 2026
mediumSoftware EngineerOnline AssessmentSoftware Engineering Fundamentals
1
0

Question

Compare JavaScript's Promise.all, Promise.any, and Promise.allSettled. Explain when each aggregate promise fulfills or rejects, what its result preserves, and how you would choose among them for three independent service calls.

Constraints & Assumptions

  • Inputs may contain promises or plain values.
  • Completion order may differ from input order.
  • A rejected operation may continue running unless it supports external cancellation.
  • Discuss the empty-iterable case for each method.

Clarifying Questions to Ask Guidance

  • Does “first” mean first in input order or first to settle? Settlement behavior and result ordering are separate.
  • Should individual errors be retained? That depends on the method and use case.
  • Is cancellation automatic after the aggregate settles? No.
  • Is one successful result enough for the caller? That is the key selection question.

What a Strong Answer Covers Guidance

  • Fail-fast rejection and ordered fulfillment array for Promise.all .
  • First fulfillment and aggregate failure for Promise.any .
  • Wait-for-everything outcome records for Promise.allSettled .
  • Correct empty-input semantics and distinction from Promise.race .
  • Practical choices, error reporting, timeouts, and explicit cancellation.

Follow-up Questions Guidance

  1. How would you cancel remaining fetches after Promise.any fulfills?
  2. How would you require at least two of three operations to succeed?
  3. Why do result arrays preserve input order even when completion order differs?
Loading comments...