In this function:
function method2(friends, callback) {
//friends is an array of objects
var ids = _.pluck(friends, 'id'),
arrays = cut(ids, 24),
//cut() splits array into smaller arrays of given length
code = require('fs').readFileSync('...').toString();
var imp,j;
async.eachSeries(arrays, function(i, cb1) {
...
vk.request('execute', {code:code}, function(err, resp, body) {
//vk.request passes its callback to node-request module
//at this point, err is null, and body.error is undefined
if(err || body.error) return cb1(err || body.error);
var arr = body.response;
for(var e in arr) {
if(!arr[e]) return cb1();
async.eachSeries(arr[e], function(i, cb) {
...
cb();
}, cb1);
}
})
}, callback);
}
function is called only once, but async calls callback many times without providing any arguments to it. I cant't see any reasons why. so what's wrong with this code?