DEV Community

Discussion on: 🚀 [GIF] Cheatsheet for Javascript Promise API methods - Promise.all, Promise.allSettled, Promise.race, Promise.any

Collapse
 
mtbisu profile image
Nguyễn Mạnh Thắng

Anyone can response this one. In promise all. When one of them is rejected. The result will immediately go to catch block or wait to the result of the rest children promises and go to catch block after? Thanks

Collapse
 
hem profile image
Hem • Edited

When one of the promises in the input array (or iterable) get rejected, Promise.all rejects as well. Refer the attached snippet.

One thing to note here is that just because Promise.all short-circuited, it doesn't, in any way, affect the execution of other passed-in promises. They just execute independently (See how P3 promise executes independently even though P2 had already rejected and short-circuited Promise.all)

Snippet : Link

Collapse
 
mtbisu profile image
Nguyễn Mạnh Thắng

Thanks. Your answer helps me a lot indeed :)