caolan / async

Async utilities for node and the browser
http://caolan.github.io/async/
MIT License
28.15k stars 2.41k forks source link

async.each/async.eachSeries does not work properly when there is another async.each/eachSeries inside the callback #1943

Open soknifedev opened 6 months ago

soknifedev commented 6 months ago

What version of async are you using? 3.2.5

Which environment did the issue occur in (Node/browser/Babel/Typescript version) NodeJS(v18.15.0)+TypeScript(v5.2.2)

What did you do? Please include a minimal reproducible case illustrating issue.

await async.eachSeries(['a', 'b'], async (item) => {
  await async.eachSeries(['c', 'd'], async (secondItem) => {
      console.log('secondItem:', secondItem)
  })
})
console.log('completed');

What did you expect to happen? Iterate over a, b, inside that iteration iterate over c, d.

What was the actual result? Iteration for c, d happens for "a" but not for "b", and the "completed" log never occurrs. (It gets stucked).

This happens too with async.each.

It works when using for await.

nathaniel-holder commented 5 months ago

I'm seeing this same behavior.

soknifedev commented 2 weeks ago

I can also confirm that this happens when using await async.filter() inside an async function.