async icon indicating copy to clipboard operation
async copied to clipboard

only first of async.series function gets called

Open AlexZeitler opened this issue 10 years ago • 2 comments

Considering this code, only the first function body is executed.

  async.series([
    function(cb) {
      let a = 1
      cb()
    },
    function(cb) {
      let b = 2;
      cb()
    } 
  ], function(err) {
    console.log('test')
  })

If I change series to parallel, every function body is executed.

  async.parallel([
    function(cb) {
      let a = 1
      cb()
    },
    function(cb) {
      let b = 2;
      cb()
    } 
  ], function(err) {
    console.log('test')
  })

I'm using this inside an function which is being called inside another async.series, so its basically this:

function outer() {
  async.series([
    function(cb) {
      inner(cb);
    },
    function(cb) {
      let b = 2;
      cb()
    } 
  ], function(err) {
    console.log('outer test')
  })
}
function inner(callback) {
  async.series([
    function(cb) {
      let a = 1
      cb()
    },
    function(cb) {
      let b = 2;
      cb()
    } 
  ], function(err) {
    console.log('inner test')
    callback()
  })
}

In outer all function bodies in async.series get executed.

AlexZeitler avatar Apr 12 '16 15:04 AlexZeitler

Tested it isolated and it works fine.

AlexZeitler avatar Apr 12 '16 16:04 AlexZeitler

Works for me also Thanks

northoutIshan avatar May 31 '17 13:05 northoutIshan