Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bandwidth Exhausted #865

Open
nonoumasy opened this issue Jan 4, 2023 · 2 comments
Open

Bandwidth Exhausted #865

nonoumasy opened this issue Jan 4, 2023 · 2 comments

Comments

@nonoumasy
Copy link

Expected behavior

Actual behavior

Steps to reproduce the behavior

@arthabus
Copy link

arthabus commented Sep 21, 2023

@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?

@arthabus
Copy link

The below pull request on the forked repo should fix it:

cuong0993#1

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

No branches or pull requests

2 participants