You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Break the huge promise chain, use a loop
By using a loop over all records instead of building a huge promise chain, we avoid the issue documented in #254 where the promise chain ends up taking up all the memory of an application.
In short, this commit allows the garbage collector to collect the small promises as they resolve, rather than building one huge chain that keeps references to the future "then"s.
The downside of this approach currently is that it relies on async/await syntax in order to allow awaits inside loops, which is what can fix the issue here. Im sure we can find a solution without this if it is significant, and we put our minds to it!
* Async-free solution with no eternal promise chain
In this approach, I have removed the dependency on async/await syntax, but also avoided eternal promise chains by using a top-level promise that allows sub-promises to compute to fulfillment before moving on.
0 commit comments