uwazi
uwazi copied to clipboard
Remove `for await` loops on distributed jobs
for await
loops are intended to be used on async iterators/generators. During the development of the sync feature as a distributed loop, we noticed that the behaviour of this loops is not strictly sequential, which can lead to unexpected effects on the implementation.
As we used that approach moving the TOC job to a distributed loop, we think moving back to a reduce loop approach is the way to implement asynchronous calls inside loops.
How about a plain old loop (for generators, maybe one of the while
s)? If I remember correctly, we have talked about ignoring the "no await in loop" rule in specific cases where it is needed.