Skip to content

Commit

Permalink
[Security Solution][Endpoint] Removes pMap and uses a for loop instead (
Browse files Browse the repository at this point in the history
#163509)

## Summary

Removes pMap and uses a for loop instead when fetching exceptions (as it
was done before) since exceptions are cached and there is no need for
parallel code here.

Original PR with previous changes:
#160387

Co-authored-by: Kibana Machine <[email protected]>
  • Loading branch information
dasansol92 and kibanamachine authored Aug 11, 2023
1 parent c8e5741 commit 81ca020
Showing 1 changed file with 6 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* 2.0.
*/

import pMap from 'p-map';
import semver from 'semver';
import { isEqual, isEmpty, chunk, keyBy } from 'lodash';
import type { ElasticsearchClient } from '@kbn/core/server';
Expand Down Expand Up @@ -223,23 +222,13 @@ export class ManifestManager {
osOptions: BuildArtifactsForOsOptions
): Promise<Record<string, InternalArtifactCompleteSchema[]>> {
const policySpecificArtifacts: Record<string, InternalArtifactCompleteSchema[]> = {};
await pMap(
allPolicyIds,
async (policyId) => {
for (const os of supportedOSs) {
policySpecificArtifacts[policyId] = policySpecificArtifacts[policyId] || [];
policySpecificArtifacts[policyId].push(
await this.buildArtifactsForOs({ os, policyId, ...osOptions })
);
}
},
{
concurrency: 5,
/** When set to false, instead of stopping when a promise rejects, it will wait for all the promises to
* settle and then reject with an aggregated error containing all the errors from the rejected promises. */
stopOnError: false,
for (const policyId of allPolicyIds)
for (const os of supportedOSs) {
policySpecificArtifacts[policyId] = policySpecificArtifacts[policyId] || [];
policySpecificArtifacts[policyId].push(
await this.buildArtifactsForOs({ os, policyId, ...osOptions })
);
}
);

return policySpecificArtifacts;
}
Expand Down

0 comments on commit 81ca020

Please sign in to comment.