eslint/no-await-in-loop Perf
What it does
This rule disallows the use of await
within loop bodies. (for, for-in, for-of, while, do-while).
Why is this bad?
It potentially indicates that the async operations are not being effectively parallelized. Instead, they are being run in series, which can lead to poorer performance.
Example
Examples of incorrect code for this rule:
javascript
async function bad() {
for (const user of users) {
const userRecord = await getUserRecord(user);
}
}
Examples of correct code for this rule:
javascript
async function good() {
await Promise.all(users.map((user) => getUserRecord(user)));
}