Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upDisallow await inside of loops (no-await-in-loop) #737
Comments
feross
added
the
enhancement
label
Jan 7, 2017
feross
added this to the
standard v9 milestone
Jan 7, 2017
This comment has been minimized.
This comment has been minimized.
|
No ecosystem impact. |
This comment has been minimized.
This comment has been minimized.
dougwilson
commented
Jan 10, 2017
|
There may be no current ecosystem impact (maybe from lack of widespread async function usage?), but I'm a little iffy on this rule. Maybe I just don't understand what I'm missing :) So my thought is that sometimes you want to go through an async loop in series, not parallel. This rule would seem to make that difficult, unless I'm missing something. |
This comment has been minimized.
This comment has been minimized.
|
@dougwilson You're precisely right. This rule does make going through an async loop in series an error. I was iffy as well. My thinking with these rules that I'm iffy on has always been to enable them and then remove them at the first sign of trouble, i.e. if any users report legit code that they're being prevented from writing. The nice thing about relaxing a rule is that you can do it in a minor version :) Happy to go either way on this one. Anyone else have input? |
This comment has been minimized.
This comment has been minimized.
|
I use await inside of for-loops frequently. The common use case? Http requests. If it's all parallel, I could inadvertently blast the service and hit rate limitations. |
This comment has been minimized.
This comment has been minimized.
|
Okay, that's enough for me. Let's skip this rule. |
feross commentedJan 7, 2017
Performing an operation on each element of an iterable is a common task. However, performing an
awaitas part of each operation is an indication that the program is not taking full advantage of the parallelization benefits ofasync/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.http://eslint.org/docs/rules/no-await-in-loop