async: Looking for a way to not exit on async.parallel on error.

Majority of my most recent use-cases involve async functions that aren’t dependent on each other, and so when some async function breaks up top, the rest of my code doesn’t execute. Wondering if there’s a simple way to do something like this without being so obtrusive to the library / so much overhead. In this case I’d like to return false on error, so I’m building an object with every property intact, if something fails everything is else is still there, and false takes the broken async functions place.

var noError = function(func) {
  return function(callback) {
    func(function(err, value) {
      if (err) return callback(null, false);
      return callback(null, value);
    });
  }
}

var parallelNoError = function(functions, callback) {
  var newFunctions = {};
  for (var func in functions) {
    newFunctions[func] = noError(functions[func]);
  }
  return async.parallel(newFunctions, callback);
}

@aearly Would love your thoughts on this one too.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 18

Most upvoted comments

Closing this in favor of #942 . There’s also the PR: #1012