@@ -516,7 +516,7 @@ export async function getWorkers(
516516 ( v ) => v . nodeBindings ,
517517 ) ;
518518 }
519- let workerPromises : Promise < Worker > [ ] = [ ] ;
519+ let successfulResults : Worker [ ] = [ ] ;
520520 let descriptors : string [ ] = [ ] ;
521521
522522 // Handle different input types
@@ -528,68 +528,75 @@ export async function getWorkers(
528528 : getFixedNames ( workers )
529529 : workers ;
530530 descriptors = names ;
531- workerPromises = descriptors . map ( ( descriptor ) =>
532- manager . createWorker (
533- descriptor ,
534- sdkVersions [ Math . floor ( Math . random ( ) * sdkVersions . length ) ] ,
535- ) ,
536- ) ;
531+ for ( const descriptor of descriptors ) {
532+ successfulResults . push (
533+ await manager . createWorker (
534+ descriptor ,
535+ sdkVersions [ Math . floor ( Math . random ( ) * sdkVersions . length ) ] ,
536+ ) ,
537+ ) ;
538+ }
537539 } else {
538540 // Record input - apply versioning if requested
539541 let entries = Object . entries ( workers ) ;
540542
541543 descriptors = entries . map ( ( [ descriptor ] ) => descriptor ) ;
542- workerPromises = entries . map ( ( [ descriptor , apiUrl ] ) =>
543- manager . createWorker ( descriptor , sdkVersions [ 0 ] , apiUrl ) ,
544- ) ;
545- }
546-
547- // Only use progress bar if there are more than 50 workers
548- const useProgressBar = workerPromises . length > 50 ;
549- let progressBar : ProgressBar | undefined ;
550-
551- if ( useProgressBar ) {
552- progressBar = new ProgressBar (
553- workerPromises . length ,
554- `Initializing ${ workerPromises . length } workers...` ,
555- ) ;
556- // Show initial progress immediately
557- progressBar . update ( 0 ) ;
558- }
559-
560- // Track all workers in parallel and update progress as each completes
561- let completedCount = 0 ;
562- const results = await Promise . allSettled (
563- workerPromises . map ( async ( workerPromise ) => {
564- try {
565- const worker = await workerPromise ;
566- completedCount ++ ;
567- if ( useProgressBar && progressBar ) {
568- progressBar . update ( completedCount ) ;
569- }
570- return worker ;
571- } catch ( error ) {
572- completedCount ++ ;
573- if ( useProgressBar && progressBar ) {
574- progressBar . update ( completedCount ) ;
575- }
576- throw error ;
577- }
578- } ) ,
579- ) ;
580-
581- // Check for any failures
582- const failedResults = results . filter (
583- ( result ) => result . status === "rejected" ,
584- ) ;
585- if ( failedResults . length > 0 ) {
586- throw failedResults [ 0 ] . reason ;
544+ for ( const descriptor of descriptors ) {
545+ successfulResults . push (
546+ await manager . createWorker (
547+ descriptor ,
548+ sdkVersions [ Math . floor ( Math . random ( ) * sdkVersions . length ) ] ,
549+ ) ,
550+ ) ;
551+ }
587552 }
588553
589- // Extract successful results
590- const successfulResults = results . map (
591- ( result ) => ( result as PromiseFulfilledResult < Worker > ) . value ,
592- ) ;
554+ // // Only use progress bar if there are more than 50 workers
555+ // const useProgressBar = workerPromises.length > 50;
556+ // let progressBar: ProgressBar | undefined;
557+
558+ // if (useProgressBar) {
559+ // progressBar = new ProgressBar(
560+ // workerPromises.length,
561+ // `Initializing ${workerPromises.length} workers...`,
562+ // );
563+ // // Show initial progress immediately
564+ // progressBar.update(0);
565+ // }
566+
567+ // // Track all workers in parallel and update progress as each completes
568+ // let completedCount = 0;
569+ // const results = await Promise.allSettled(
570+ // workerPromises.map(async (workerPromise) => {
571+ // try {
572+ // const worker = await workerPromise;
573+ // completedCount++;
574+ // if (useProgressBar && progressBar) {
575+ // progressBar.update(completedCount);
576+ // }
577+ // return worker;
578+ // } catch (error) {
579+ // completedCount++;
580+ // if (useProgressBar && progressBar) {
581+ // progressBar.update(completedCount);
582+ // }
583+ // throw error;
584+ // }
585+ // }),
586+ // );
587+
588+ // // Check for any failures
589+ // const failedResults = results.filter(
590+ // (result) => result.status === "rejected",
591+ // );
592+ // if (failedResults.length > 0) {
593+ // throw failedResults[0].reason;
594+ // }
595+
596+ // // Extract successful results
597+ // const successfulResults = results.map(
598+ // (result) => (result as PromiseFulfilledResult<Worker>).value,
599+ // );
593600
594601 // Add all successful workers to the manager
595602 for ( const worker of successfulResults ) {
@@ -618,12 +625,11 @@ function getNextFolderName(): string {
618625 const dataPath = path . resolve ( process . cwd ( ) , ".data" ) ;
619626 let folder = "a" ;
620627 if ( fs . existsSync ( dataPath ) ) {
621- const existingFolders = fs
622- . readdirSync ( dataPath )
623- . filter ( ( f ) => / ^ [ a - z ] $ / . test ( f ) ) ;
624- folder = String . fromCharCode (
625- "a" . charCodeAt ( 0 ) + ( existingFolders . length % 26 ) ,
626- ) ;
628+ const chars = "abcdefghijklmnopqrstuvwxyz0123456789" ;
629+ folder = Array . from (
630+ { length : 32 } ,
631+ ( ) => chars [ Math . floor ( Math . random ( ) * chars . length ) ] ,
632+ ) . join ( "" ) ;
627633 }
628634 return folder ;
629635}
0 commit comments