Unlike its predecessor, Promise.allSettled() does not care if a promise succeeds or fails in terms of its own resolution. It waits for every promise in the input array to "settle"—meaning it has either been fulfilled or rejected. Once all tasks have reached a final state, it returns an array of objects that describe the outcome of each operation.
Each object in the resulting array contains a status property, which is either "fulfilled" or "rejected". If fulfilled, the object contains a value representing the successful data; if rejected, it contains a reason explaining the failure. This structure allows developers to handle the results with far greater granularity:
const results = await Promise.allSettled([
fetch("/api/user").then((r) => r.json()),
fetch("/api/posts").then((r) => r.json()),
fetch("/api/stats").then((r) => r.json()),
]);
const [user, posts, stats] = results.map((r) =>
r.status === "fulfilled" ? r.value : null
);
if (stats === null)
console.warn("Unable to load statistics:", results[2].reason);
By adopting this pattern, the dashboard becomes significantly more robust. The application can now render the user information and the post list immediately, even if the statistics API is down. The user is provided with the data that is available, and the developer can implement a "graceful degradation" strategy, such as displaying a "Statistics temporarily unavailable" notice or a retry button specifically for that failed block. Furthermore, the error information is preserved, allowing for more accurate logging and debugging without disrupting the end-user’s workflow.
Applying It to Your Project
The decision to use Promise.allSettled() over Promise.all() should be guided by the relationship between the tasks being performed. The primary rule for developers is to evaluate independence: if the tasks are independent of each other and the application can provide value even with partial results, Promise.allSettled() is the superior choice.
This applies to a wide range of real-world scenarios beyond simple dashboards. For instance, an import utility processing a batch of files should not necessarily stop if one file is corrupted; it should process all valid files and report a summary of errors at the end. Similarly, a status monitoring screen checking the health of various microservices should report the status of each individual service, rather than failing entirely if one service is unreachable.
Another common use case is in communication features, such as an application sending notification emails to a list of recipients. If one email address is malformed and causes a rejection, it should not prevent the other valid recipients from receiving their messages. By using Promise.allSettled(), the system can ensure maximum delivery while identifying specific failures for later correction.
However, it is important to note that Promise.all() still has a vital place in software architecture. In scenarios where tasks are interdependent—such as a transaction where you must create an order record, deduct stock from inventory, and process a payment—the fail-fast behavior is exactly what is required. In these cases, if any step fails, the entire process must be halted to maintain data integrity.
