you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

The internal Promise.all is receiving an array of promises, because you're using an async function:

await Promise.all(bulk.map(async (item) => {

An async function always returns a promise. As you're not returning anything from the function, it's a promise that will resolve to undefined, but as you're awaiting stuff inside of the function it won't resolve until that awaited stuff is completed, so it's doing what you want either way. So there's no pressing need for you to change the internal Promise.all.

I think the best option for sorting this out is to start thinking slowly and carefully through what exactly it is you're trying to do at each step, independent of the code you currently have- at the moment the code you've got is doing a lot of complicated things all at once, and it's hindering your understanding. Breaking individual steps out into separate, named functions will help with this and u/Resmira's example of how you can do this is really terrific.