node-firestore-import-export
node-firestore-import-export copied to clipboard
Bandwidth Exhausted
Expected behavior
Actual behavior
Steps to reproduce the behavior
@nonoumasy @cuong0993 I think I figured the problem.
The internal logic that was supposed to limit the number of promises to be executed in parallel, the way it's implemented in the lib, it doesn't work.
Internal function batchExecutor accepts a list of promises, but the moment that list is built, all the promises are already launched and it starts to write all the documents and apply that recursively even before it reaches batchExecutor "launching" logic. batchExecutor just waits before all the promises are resolved, but that doesn't help as it doesn't limit the number of promises being executed at the same time.
That leads to random hangs or Bandwidth Exhausted when the database is big enough.
Instead batchExecutor should expect an array of factory functions that returns promises and unwrap only a batch of those functions, then wait till batch is completed and proceed to unwrapping the next batch etc
I'll fix it and send a pull request to @cuong0993, assuming you can accept and merge it.
@cuong0993 is your version also on npm?
The below pull request on the forked repo should fix it:
https://github.com/cuong0993/node-firestore-import-export/pull/1