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 fails when executed in the different node.js context #302

Closed
alex-netkachov opened this issue Apr 29, 2013 · 4 comments
Closed

Comments

@alex-netkachov
Copy link

The following code fails with the "First argument to waterfall must be an array of functions" error in node.js:

require('vm').runInNewContext(
    'async.waterfall([ ], function (err) { console.log(err); });',
    { async : require('async'), console : console }
);

It looks like after node.js creates new environment, the following array comparison becomes invalid:

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

Maybe it is better to use native Array.isArray function when it is available?

Thanks.

@brianmaissy
Copy link
Contributor

This is related to both #294 and #179. I'll work on a comprehensive fix. Basically I'll replace all instances of Array type checking with a local checker function, which will use .isArray if available, and if not will fall down to the .toString approach. @caolan sounds good?

@patrickod
Copy link

+1 for this to be shipped. Just encountered it again today.

@theabraham
Copy link

+1 on this too. I'm having this same issue in node-webkit (issue #344.)

@heiwad
Copy link

heiwad commented Oct 21, 2013

I ran into this issue today in a node REPL in Emacs on Ubuntu.
The code posted at http://stackoverflow.com/a/17417137/2904811 fixed the issue for me.

@caolan caolan closed this as completed Mar 28, 2014
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

6 participants