ESERVFAIL
- The application queries forapi.example.com
, there is a SERVFAIL error thrown back and the call fails.
Promise.all
will catch
(stop the execution) if at least one of the async functions is throwing an error. So you can't use Promise all in this case, and for 10000 async calls it is a bad practice, you can easily dump out all your memory.
One way to solve your problem is implement a parallel limited queue
which will resolve the errors and the results, and then you just can manage to output the results in a proper manner.
One library that I found that implements the limited queue is cwait
From their documentation:
import * as Promise from 'bluebird';
import {TaskQueue} from 'cwait';
/** Queue allowing 3 concurrent function calls. */
var queue = new TaskQueue(Promise, 3);
Promise.map(list, download); // Download all listed files simultaneously.
Promise.map(list, queue.wrap(download))); // Download 3 files at a time.