I will elaborate what I am trying to do and what I am expecting to get
I have a list of templates that i need to generate. Using the jsreport-aws-s3-storage I was able to successfully upload the files to S3.

1st Try

for(var i in templates){ var resp_pdf = await jsreport.render({ template: { name: templates[i].name recipe: 'chrome-pdf' }, data: templates[i].data, options: { "reports": { "async": true, "blobName": templates[i].name}, "reportName": templates[i].name } }) }

However I need to find a way to make a callback call once all files has been generated and uploaded to S3.

For that reason I tried first to put the above code at beforeRender of the main template and I was expecting that doing the callback from afterRender will take place only once all all files are on S3.

await axios.get(CALLBACK_URL...

But somehow, I was getting the response sooner, before all files has been sent to S3.

2nd Try
I tried to count the generated files and then fire the CALLBACK as following

toRender = 100; for(var i in templates){ var resp_pdf = await jsreport.render({ ... }) if(resp_pdf) rendered++; if(rendered==toRender){ // CALLBACK } }

Using this setup I noticed that the callback was fired as soon as all PDF files has been generated regardless if all of them has finished upload to s3 or not.

I am open for suggestions, Is there a better way to fire callback once all files has been uploaded ?

Thanks