Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

async.waterfall/async.series fail if have more than 5/6 functions #731

Closed
chuongle opened this issue Mar 13, 2015 · 1 comment
Closed

async.waterfall/async.series fail if have more than 5/6 functions #731

chuongle opened this issue Mar 13, 2015 · 1 comment

Comments

@chuongle
Copy link

When I use async.waterfall, it fails if I have more that 5 functions. When I use async.series, it fails if I have more than 6 functions. Sometimes async.series works with more than 6 but if I refresh the page then it stops working. Does async.waterfall/async.series have any limitation? How do I solve this issue? I'm new to javascript so can you guys help me with this? Below is the code that i try to work on

async.series([
  function(callback) {
    async.waterfall([
      function(callback) {
        bars.results(function(results){
          results.forEach(function(result, index){
            result.marker = bars.markers[index];
          })
          callback(null, results)
        });
      }, function(results_with_distance, callback) {
        // Sort array based on distance
        results_with_distance.sort(compare);
        callback(null, results_with_distance);
      }
    ], function(err, final_results){
      callback(null, final_results);
    });
  },
  function(callback) {
    async.waterfall([
      function(callback) {
        coffee.results(function(results){
          results.forEach(function(result, index){
            result.marker = coffee.markers[index];
          })
          callback(null, results)
        });
      }, function(results_with_distance, callback) {
        // Sort array based on distance
        results_with_distance.sort(compare);
        callback(null, results_with_distance);
      }
    ], function(err, final_results){
      callback(null, final_results);
    });
  },
  function(callback) {
    async.waterfall([
      function(callback) {
        restaurants.results(function(results){
          results.forEach(function(result, index){
            result.marker = restaurants.markers[index];
          })
          callback(null, results)
        });
      }, function(results_with_distance, callback) {
        // Sort array based on distance
        results_with_distance.sort(compare);
        callback(null, results_with_distance);
      }
    ], function(err, final_results){
      callback(null, final_results);
    });
  },
  function(callback) {
    async.waterfall([
      function(callback) {
        schools.results(function(results){
          results.forEach(function(result, index){
            result.marker = schools.markers[index];
          })
          callback(null, results)
        });
      }, function(results_with_distance, callback) {
        // Sort array based on distance
        results_with_distance.sort(compare);
        callback(null, results_with_distance);
      }
    ], function(err, final_results){
      callback(null, final_results);
    });
  },
  function(callback) {
    async.waterfall([
      function(callback) {
        parks.results(function(results){
          results.forEach(function(result, index){
            result.marker = parks.markers[index];
          })
          callback(null, results)
        });
      }, function(results_with_distance, callback) {
        // Sort array based on distance
        results_with_distance.sort(compare);
        callback(null, results_with_distance);
      }
    ], function(err, final_results){
      callback(null, final_results);
    });
  },
  function(callback) {
    async.waterfall([
      function(callback) {
        shoppings.results(function(results){
          results.forEach(function(result, index){
            result.marker = shoppings.markers[index];
          })
          callback(null, results)
        });
      }, function(results_with_distance, callback) {
        // Sort array based on distance
        results_with_distance.sort(compare);
        callback(null, results_with_distance);
      }
    ], function(err, final_results){
      callback(null, final_results);
    });
  },
  function(callback) {
    async.waterfall([
      function(callback) {
        groceries.results(function(results){
          results.forEach(function(result, index){
            result.marker = groceries.markers[index];
          })
          callback(null, results)
        });
      }, function(results_with_distance, callback) {
        // Sort array based on distance
        results_with_distance.sort(compare);
        callback(null, results_with_distance);
      }
    ], function(err, final_results){
      callback(null, final_results);
    });
  },
], function(err, results) {
  console.log(results);
})
@aearly
Copy link
Collaborator

aearly commented Mar 13, 2015

There is no limitation. There likely is an issue with your 6th (or possibly 5th) function.

@aearly aearly closed this as completed May 19, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants