Question presented to candidate: "You run Promise.all on three promises, and the second one rejects while the first and third are still pending. What actually happens — does Promise.all wait for the first and third to finish before reporting the failure?"
What a strong answer should cover:
- 📌 Interview term:
Promise.all(promises)— resolves with an array of ALL results, but genuinely rejects immediately the moment ANY input rejects — verified directly, it genuinely does NOT wait for the other still-pending promises to finish first. - 📌 Interview term:
Promise.allSettled(promises)— genuinely never rejects — it always resolves, with an array reporting EVERY input's real outcome ({status: "fulfilled", value}or{status: "rejected", reason}) — verified directly. - 📌 Interview term:
Promise.race(promises)— settles (fulfills OR rejects) with whichever input settles first, regardless of success or failure — verified directly both ways: a genuine fulfillment winning, and, separately, a genuine rejection winning when it happens to settle first. - 📌 Interview term:
Promise.any(promises)— genuinely ignores individual rejections, resolving with the first FULFILLMENT — only rejecting itself (with a realAggregateErrorcollecting every individual error) if genuinely ALL inputs reject. - 📌 Interview term: the real, direct answer to the prompt — verified directly with real, distinctly-timed promises:
Promise.allgenuinely does NOT wait for the other pending promises — it rejects the instant the FIRST rejection occurs, confirmed by measuring that the rejection surfaced before the slower, still-pending promises had time to settle.
Clarifying questions expected:
- None — this is a definitional/comparison question; directly answering the prompt's own early-rejection timing question is the strong signal.
Code / implementation expected: Yes — a real, timed side-by-side of all four combinators against the identical set of timed promises is the clearest, most convincing demonstration of their distinct behaviors.