/ / async.map nie wywołuje cb z zagnieżdżonym wodospadem - javascript, async.js

async.map nie wywołuje cb z wodospadem zagnieżdżonym - javascript, async.js

Mam z tym problem async.

To jest mój kod:

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); // This are calling cb(new Error("bla"))
}
], cb) // at this point, I can read err
}, cb) // This is never called
}
], function(err, items) {
if (err) {
log.error(LOG_CTX, err);
} else {
log.verbose(LOG_CTX, items);
log.verbose(LOG_CTX, items.length);
}
})
}

Co próbowałem ...

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);  // This prints ERR
cb(err);
})
}, function(err) {
log.error("2", err);  // this is never called
cb(err);
})

czego mi brakuje? Dzięki za pomoc.

Odpowiedzi:

0 dla odpowiedzi № 1

Odkryłem, że jeśli iterator podczas mapowaniawywołuje cb z błędem, zostanie wywołany główny cb, ale mapa będzie kontynuowana. Dlatego nie widziałem błędu, wyjście zostało pokryte wyjściem ważnych odpowiedzi.

Jeśli iterator przekazuje błąd do tego wywołania zwrotnego, główne wywołanie zwrotne (dla funkcja mapy) jest natychmiast wywoływana z błędem

Mapa asynchroniczna #