تخطَّ إلى المحتوى

Promise All Misuse (ARCH3032)

هذا المحتوى غير متوفر بلغتك بعد.

Key typescript.async.promise-all-misuse · Severity info · Category async

Awaiting independent promises sequentially where Promise.all could parallelize, or using Promise.all where Promise.allSettled is needed to avoid losing results on the first rejection, hurts throughput and correctness.

async function load(): Promise<[User, Order[]]> {
const user = await fetchUser(); // sequential
const orders = await fetchOrders(); // independent but waited
return [user, orders];
}
async function load(): Promise<[User, Order[]]> {
const [user, orders] = await Promise.all([fetchUser(), fetchOrders()]);
return [user, orders];
}

Parallelize independent operations with Promise.all; use Promise.allSettled when you need to collect partial failures.