What is AggregateError in JavaScript?
An error type thrown by Promise.any when all promises reject. It has an errors property containing an array of all the individual rejection reasons. This lets you see why each promise failed.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in Promise.all vs allSettled vs race vs any in JavaScript
Promise.all waits for all and rejects if any rejects (fast fail). allSettled waits for all and never rejects (returns status objects). race returns the first to settle (fulfilled or rejected). any returns the first to fulfill (rejects with AggregateError if all reject).
When you want all results even if some promises reject (partial success). Promise.all rejects if any promise rejects. allSettled waits for all and returns an array of { status, value/reason } objects, so you can handle each result individually.
When you want the first promise to settle (fulfilled or rejected). Common use: implementing a timeout. Race the operation against a timeout promise; whichever settles first wins.
Still have questions?
Browse all our FAQs or reach out to our support team
