Skip to content
This repository has been archived by the owner on Oct 13, 2022. It is now read-only.

no-await-in-loop eslint error on service-worker #176

Open
soullivaneuh opened this issue Oct 20, 2019 · 0 comments
Open

no-await-in-loop eslint error on service-worker #176

soullivaneuh opened this issue Oct 20, 2019 · 0 comments

Comments

@soullivaneuh
Copy link

I have a global eslint configuration for all my company projects.

It warns me at this part:

for (const key of keys) {
if (key !== ASSETS) await caches.delete(key);
}

According to the rule: https://eslint.org/docs/rules/no-await-in-loop

Performing an operation on each element of an iterable is a common task. However, performing an await as part of each operation is an indication that the program is not taking full advantage of the parallelization benefits of async/await.
Usually, the code should be refactored to create all the promises at once, then get access to the results using Promise.all(). Otherwise, each successive operation will not start until the previous one has completed.

What do you think? Can this part be improve or is it a false positive?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant