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

during crashes while passing param to callback fn #1121

Closed
Niels-Be opened this issue Apr 21, 2016 · 3 comments
Closed

during crashes while passing param to callback fn #1121

Niels-Be opened this issue Apr 21, 2016 · 3 comments

Comments

@Niels-Be
Copy link
Contributor

I called the iteratee callback of during with an additional parameter and what happened is that this parameter was passed to the test function as first parameter.

const async=require("async");

var count = 0;
async.during((callback) => {
  console.log(callback);
  callback(null, count < 3);
}, (callback) => {
  count++;
  callback(null, "Some String");
}, (err) => {
  console.log("Done");
});

Output:

[Function]
Some String
/app/test.js:6
  callback(null, count < 3);
  ^

TypeError: callback is not a function
    at /app/test.js:6:3
    at /app/node_modules/async/lib/async.js:825:22
    at /app/node_modules/async/lib/async.js:167:37
    at /app/test.js:9:3
    at check (/app/node_modules/async/lib/async.js:833:17)
    at /app/test.js:6:3
    at Object.async.during (/app/node_modules/async/lib/async.js:839:9)
    at Object.<anonymous> (/app/test.js:4:7)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)

Is this intended or a bug?

@megawac
Copy link
Collaborator

megawac commented Apr 21, 2016

during passes any arguments passed by the iteratee function (2nd function) to the test function (1st function). This is intended behaviour.

var count = 0;
async.during(function(callback1) {
  callback1 = arguments[arguments.length-1]
  callback1(null, count < 3);
}, function(callback2) {
  count++;
  callback2(null, "Some String");
}, (err) => {
  console.log("Done");
});

@Niels-Be
Copy link
Contributor Author

Ok, you should document this

@megawac
Copy link
Collaborator

megawac commented Apr 21, 2016

If you like you can submit a pull request to clarify the documentation
On Apr 21, 2016 7:10 PM, "WaeCo" notifications@github.com wrote:

Ok, you should document this


You are receiving this because you modified the open/close state.
Reply to this email directly or view it on GitHub
#1121 (comment)

@aearly aearly added the docs label Apr 25, 2016
aearly added a commit that referenced this issue Apr 26, 2016
Updated description of during #1121
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants