diff --git a/services/apps/premium/members_enrichment_worker/src/activities/getMembers.ts b/services/apps/premium/members_enrichment_worker/src/activities/getMembers.ts index f2b597e80..e97654ec6 100644 --- a/services/apps/premium/members_enrichment_worker/src/activities/getMembers.ts +++ b/services/apps/premium/members_enrichment_worker/src/activities/getMembers.ts @@ -39,9 +39,16 @@ export async function getMaxConcurrentRequests( ): Promise { const serviceMap: Partial> = {} const distinctEnrichableSources = new Set() + let maxConcurrentRequestsInAllSources = 0 for (const source of possibleSources) { serviceMap[source] = EnrichmentSourceServiceFactory.getEnrichmentSourceService(source, svc.log) + if (serviceMap[source].maxConcurrentRequests > maxConcurrentRequestsInAllSources) { + maxConcurrentRequestsInAllSources = Math.max( + maxConcurrentRequestsInAllSources, + serviceMap[source].maxConcurrentRequests, + ) + } } for (const member of members) { const enrichmentInput = await getEnrichmentInput(member) @@ -57,7 +64,7 @@ export async function getMaxConcurrentRequests( }) } - let smallestMaxConcurrentRequests = Infinity + let smallestMaxConcurrentRequests = maxConcurrentRequestsInAllSources Array.from(distinctEnrichableSources).forEach(async (source) => { smallestMaxConcurrentRequests = Math.min(