javascript - async.map doesn't call cb with a nested waterfall -
i have trouble async.
this code:
main.prototype._onlygeolinks = function() { var redis = redisclient.client , getkeys = function(key, cb) { redis.keys(key, cb); } , count = 0 // cb = null; async.waterfall([ function(cb) { async.concat([ 'events:*' , 'news:*:*:*:*' , 'deals:*' ], getkeys, cb); }, function(keys, cb) { // iterate keys async.map(keys, function(key, cb) { async.waterfall([ function(cb) { redis.get(key, cb); }, function(item, cb) { log.verbose(log_ctx, 'parsing item.. %d', ++count); geohelper.parse(item, cb); // calling cb(new error('bla')) } ], cb) // @ point, can read err }, cb) // never called } ], function(err, items) { if (err) { log.error(log_ctx, err); } else { log.verbose(log_ctx, items); log.verbose(log_ctx, items.length); } }) }
what i've tried...
async.map(keys, function(key, cb) { async.waterfall([ function(cb) { redis.get(key, cb); }, function(item, cb) { log.verbose(log_ctx, 'parsing item.. %d', ++count); geohelper.parse(item, cb); } ], function(err) { log.error('1', err); // prints err cb(err); }) }, function(err) { log.error('2', err); // never called cb(err); })
what missing? help.
i've found if iterator during mapping calls cb error, main cb called map continue. why didn't saw error, output covered output of valid responses.
if iterator passes error callback, main callback (for map function) called error
Comments
Post a Comment