in src/task/WhenAllTask.ts [33:48]
public trySetValue(child: AtomicTask): void {
if (child.stateObj === TaskState.Completed) {
// We set the result only after all sub-tasks have completed
if (this.children.every((c) => c.stateObj === TaskState.Completed)) {
// The result is a list of all sub-task's results
const results = this.children.map((c) => c.result);
this.setValue(false, results);
}
} else {
// If any task failed, we fail the entire compound task
if (this.firstError === undefined) {
this.firstError = child.result as Error;
this.setValue(true, this.firstError);
}
}
}