I am planning on running a large number of queries on firebase which could grow to the order of a few hundred thousand to even millions. I've been using Promise.all()
to resolve most of my queries but as the requests grow Promise.all()
seems to just stop running at a random number.Ive looked into using Promise.map()
but Im not sure if the concurrency will solve the problem. Thank you for your help.
Below is a simplified example as you can see it appears to just time out without throwing any error:
var promises = [];
var i = 0;
for(var x = 0; x<1000000; x++){
const promise = new Promise((resolve, reject) => {
setTimeout(() => {
i += 1;
resolve(i);
}, 10);
});
promises.push(promise);
}
Promise.all(promises).then((value) => {
console.log(value)
}).catch((error) => {
console.log("Error making js node work:" + error);
})