Performance Characteristics of Combinators
You'll learn when each Promise combinator resolves or rejects relative to its input promises.
Understanding Timing Behavior
Each Promise combinator has different timing characteristics that affect when it settles (resolves or rejects):
Promise.all resolves when all promises fulfill, but rejects as soon as any promise rejects. This means if the third promise in an array of ten rejects immediately, Promise.all rejects right away—it doesn't wait for the remaining seven.
Promise.race settles as soon as any promise settles (fulfilled or rejected). The fastest promise wins, regardless of outcome. The other promises continue executing in the background, but their results are ignored.
Promise.allSettled always waits for every promise to settle, whether fulfilled or rejected. It never short-circuits. This makes it slower than Promise.all in failure scenarios, but you're guaranteed complete results.
Promise.any resolves when the first promise fulfills, but only rejects if all promises reject. It's the optimistic mirror of Promise.all: it waits for success but short-circuits on the first win.
Performance Implications
Think of these like different race rules:
Promise.all: Everyone must finish; stop if anyone quitsPromise.race: First across the line winsPromise.allSettled: Everyone must finish, no exceptionsPromise.any: First successful finish wins; fail only if everyone quits
The combinator you choose affects both execution time and resource usage. Short-circuiting combinators (Promise.all on rejection, Promise.any on fulfillment, Promise.race always) can save time but don't cancel remaining promises—they continue running in the background.
Key Takeaway: Choose combinators based on timing needs—Promise.race for speed, Promise.allSettled for completeness, Promise.all for dependency, and Promise.any for redundancy.