I have several functions set up like this:
private async p1(): Promise<Result> {
let p1;
// Do some operations.
return p1;
}
private async p5(): Promise<void> {
// Make a call to an external API.
}
Some of these functions contain a return
, while others do not. Each function serves a specific purpose and operates independently.
I am attempting to execute all of these functions asynchronously using Promise.all() to run them in parallel with fast fail-safe capability. In total, I have around 15 function calls arranged as shown in the snippet below:
let [x1, x2, x3] = await Promise.all([
this.p1,
this.p2,
this.p3,
this.p4,
this.p5,
this.p6,
this.p7,
this.p8,
...
this.p15
]);
However, when attempting this setup, I encounter the following error message:
src/app/view-models/index.ts:69:37 - error TS2345: Argument of type '(Promise<void> | Promise<Result>)[]' is not assignable to parameter of type 'Iterable<void | PromiseLike<void>>'.
(Details of error message omitted for brevity)
If I reduce the number of function calls to just 11 or less, everything works fine without any errors. But adding the 12th function call triggers the mentioned error. Is there a solution to this issue that I might be overlooking?