File tree Expand file tree Collapse file tree 2 files changed +37
-27
lines changed
Expand file tree Collapse file tree 2 files changed +37
-27
lines changed Original file line number Diff line number Diff line change @@ -145,15 +145,22 @@ async function start() {
145145 // Process multiple protected data
146146 if ( bulkSize > 0 ) {
147147 console . log ( `Processing ${ bulkSize } protected data...` ) ;
148- const processPromises = new Array ( bulkSize ) . fill ( null ) . map ( ( _ , index ) =>
149- processProtectedData ( {
150- index : index + 1 ,
148+ const results = [ ] ;
149+ // Process each protected data one by one to avoid rate limiting issues
150+ for ( let index = 1 ; index <= bulkSize ; index += 1 ) {
151+ // eslint-disable-next-line no-await-in-loop
152+ const protectedDataResult = await processProtectedData ( {
153+ index,
151154 IEXEC_IN ,
152155 appDeveloperSecret,
153156 requesterSecret,
154- } )
155- ) ;
156- const results = await Promise . all ( processPromises ) ;
157+ } ) ;
158+ results . push ( protectedDataResult ) ;
159+ // eslint-disable-next-line no-await-in-loop
160+ await new Promise ( ( res ) => {
161+ setTimeout ( res , 1000 ) ;
162+ } ) ; // Add a delay to avoid rate limiting
163+ }
157164 const successCount = results . filter ( ( r ) => r . success === true ) . length ;
158165 const errorCount = results . filter ( ( r ) => r . success !== true ) . length ;
159166 result = {
Original file line number Diff line number Diff line change @@ -875,26 +875,29 @@ describe('sendEmail', () => {
875875 await expect ( start ( ) ) . resolves . toBeUndefined ( ) ;
876876 const { result, computed, files } = await readOutputs ( IEXEC_OUT ) ;
877877 // Verify bulk processing result structure
878- expect ( result ) . toStrictEqual ( {
879- success : true ,
880- totalCount : 2 ,
881- successCount : 2 ,
882- errorCount : 0 ,
883- results : [
884- {
885- index : 1 ,
886- protectedData : process . env . IEXEC_DATASET_1_FILENAME ,
887- isEmailValid : true ,
888- success : true ,
889- } ,
890- {
891- index : 2 ,
892- protectedData : process . env . IEXEC_DATASET_2_FILENAME ,
893- isEmailValid : true ,
894- success : true ,
895- } ,
896- ] ,
897- } ) ;
878+ expect ( result ) . toStrictEqual (
879+ {
880+ success : true ,
881+ totalCount : 2 ,
882+ successCount : 2 ,
883+ errorCount : 0 ,
884+ results : [
885+ {
886+ index : 1 ,
887+ protectedData : process . env . IEXEC_DATASET_1_FILENAME ,
888+ isEmailValid : true ,
889+ success : true ,
890+ } ,
891+ {
892+ index : 2 ,
893+ protectedData : process . env . IEXEC_DATASET_2_FILENAME ,
894+ isEmailValid : true ,
895+ success : true ,
896+ } ,
897+ ] ,
898+ } ,
899+ 10000
900+ ) ;
898901 // Verify computed.json structure
899902 expect ( computed ) . toStrictEqual ( {
900903 'deterministic-output-path' : `${ IEXEC_OUT } /result.json` ,
@@ -921,7 +924,7 @@ describe('sendEmail', () => {
921924 } ) ;
922925 // Verify no extra files were created
923926 expect ( files . length ) . toBe ( 2 ) ;
924- } ) ;
927+ } , 10000 ) ;
925928 } ) ;
926929 }
927930 } ) ;
You can’t perform that action at this time.
0 commit comments