Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Waterfall with {} input #195

abrkn opened this Issue · 8 comments

4 participants


No description provided.


@abrkn could you clarify the issue/request?


I may be able to elaborate on this request since I think I just ran into it.

async.waterfall() works when you pass in an array of functions, but does not work if you pass in an object of named functions. async will just immediately invoke the final callback, without calling any of the tasks.

This works as expected:

function() {...},
function(err, results){

This does nothing but call the final function:

f1: function() {...},
f2: function(){...}
function(err, results){

In the 2nd, nonworking example, if you change waterfall to series, it works as expected.


I don't think this is possible, since the order of the functions needs to be well-defined in waterfall, and an object's attributes aren't ordered. See also #187


That makes sense! The waterfall() function should probably check the input parameters to catch this error then.


What do you mean by catch the error? When it calls the callback it should provide an error instead of failing silently? That makes sense to me. @caolan, thoughts?


Yes, through an assertion, exception, or through the error parameter into the callback, it would be nice to alert the programmer that he is using the function in an unsupported way, especially since that 'unsupported way' is consistent with other functions in the library.


I definitely think it should be through the error parameter, not by throwing an exception, but I agree with you. If @caolan likes this, I'll submit a pull request. Something along the lines of

if (tasks.constructor !== Array) {
  var err = new Error('First argument to waterfall must be an array of functions');
}else ...

@brianmaissy yep, looks good to me. A pull request with a test would be much appreciated.

@caolan caolan closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.