tezvyn:

Promise.allSettled(): Never Fail a Batch of Promises

Source: developer.mozilla.orgadvanced

Promise.allSettled() waits for every promise in a set to finish, success or fail, without short-circuiting. Use it for independent tasks, like multiple API calls, where you need the outcome of each.

Promise.allSettled() acts like a patient manager, waiting for every promise in a collection to settle (fulfill or reject) before proceeding. Unlike Promise.all(), it never short-circuits on failure. This is ideal for running independent async tasks, like multiple API calls, where you need the outcome of every single one. The main footgun is forgetting it never rejects; your .catch() block on allSettled itself won't fire for individual promise failures. You must inspect each result object's 'status' property.

Read the original → developer.mozilla.org

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Promise.allSettled(): Never Fail a Batch of Promises · Tezvyn