Use for loop instead of promise pool

This commit is contained in:
Sam Carlton 2022-07-21 13:11:47 -05:00
parent 01a5d15147
commit b6b4967208

View file

@ -3,7 +3,6 @@ import { dirname, basename } from 'path'
import fs from 'fs-extra' import fs from 'fs-extra'
import dotenv from 'dotenv' import dotenv from 'dotenv'
import semver from 'semver' import semver from 'semver'
import { PromisePool } from '@supercharge/promise-pool'
import memoize from 'fast-memoize' import memoize from 'fast-memoize'
import has from 'just-has' import has from 'just-has'
@ -241,6 +240,7 @@ class BuildLists {
// Sort versions by semver // Sort versions by semver
const versions = Object.entries( versionsObject ).sort( ( [ aVersionRaw ], [ bVersionRaw ] ) => { const versions = Object.entries( versionsObject ).sort( ( [ aVersionRaw ], [ bVersionRaw ] ) => {
// console.log( 'a, b', aVersionRaw, bVersionRaw )
const aVersion = normalizeVersion( aVersionRaw ) const aVersion = normalizeVersion( aVersionRaw )
const bVersion = normalizeVersion( bVersionRaw ) const bVersion = normalizeVersion( bVersionRaw )
@ -450,17 +450,16 @@ class BuildLists {
const apiListDirectory = `${ apiDirectory }/${ listOptions.endpointPrefix }` const apiListDirectory = `${ apiDirectory }/${ listOptions.endpointPrefix }`
const poolSize = 1000 // const poolSize = 1000
// Store app bundles to memory // Store app bundles to memory
await this.getSavedAppBundles({ await this.getSavedAppBundles({
keepBundlesInMemory: true keepBundlesInMemory: true
}) })
const { errors } = await PromisePool // await Promise.all( this.getListArrayMemoized( listOptions.name ).map( async ( listEntry ) => {
.withConcurrency( poolSize ) for ( const listEntry of this.getListArrayMemoized( listOptions.name ) ) {
.for( this.getListArrayMemoized( listOptions.name ) )
.process(async ( listEntry, index, pool ) => {
// console.log('listEntry', listEntry) // console.log('listEntry', listEntry)
const { const {
@ -516,10 +515,6 @@ class BuildLists {
// Write the endpoint to JSON // Write the endpoint to JSON
await this.saveToJson( saveableEntry, endpointPath ) await this.saveToJson( saveableEntry, endpointPath )
})
if ( errors.length !== 0 ) {
throw new Error( errors )
} }
// Count saved files // Count saved files