Properly batch nested promises in Node
In this line: let images = await Promise.all(batches.map(run_batch)); You are trying to run ALL the batches in parallel which is defeating your chunking entirely. You could use a regular for loop with await instead of the .map() so you runva batch, wait for it to finish, then run the next batch. let allResults = []; … Read more