Open gengxuelei opened 8 years ago
async.mapLimit(arr,2, function(item, callback) { log('1.5 enter: ' + item.name); setTimeout(function() { log('1.5 handle: ' + item.name); if(item.name==='Jack') callback('myerr'); else callback(null, item.name+'!!!'); }, item.delay); }, function(err, results) { log('1.5 err: ', err); log('1.5 results: ', results); }); //57.797> 1.5 enter: Jack //57.800> 1.5 enter: Mike //57.900> 1.5 handle: Mike //57.900> 1.5 enter: Freewind //58.008> 1.5 handle: Jack //58.009> 1.5 err: myerr //58.009> 1.5 results: [ undefined, 'Mike!!!' ] //58.208> 1.5 handle: Freewind //58.208> 1.5 enter: Test //58.273> 1.5 handle: Test
经测试,在window 7 x64,node5.3.0中运行,test并不会进入队列,实际运行结果为: 25.466> 1.5 enter: Jack 25.467> 1.5 enter: Mike undefined > 25.568> 1.5 handle: Mike 25.568> 1.5 enter: Freewind 25.667> 1.5 handle: Jack 25.667> 1.5 err: myerr 25.668> 1.5 results: [ undefined, 'Mike!!!' ] 25.869> 1.5 handle: Freewind 中间蹦出个undefined是什么鬼,后面运行完出了一个空行,然后并没有test 根据each.js中的介绍,出现错误执行完当前批次的任务,后续任务应该不会进入队列啊 async_demo中没有issue,只好在这弄了
可能是实现变更了吧。当时这个输入也是直接复制出来的。老项目了。。
async.mapLimit(arr,2, function(item, callback) { log('1.5 enter: ' + item.name); setTimeout(function() { log('1.5 handle: ' + item.name); if(item.name==='Jack') callback('myerr'); else callback(null, item.name+'!!!'); }, item.delay); }, function(err, results) { log('1.5 err: ', err); log('1.5 results: ', results); }); //57.797> 1.5 enter: Jack //57.800> 1.5 enter: Mike //57.900> 1.5 handle: Mike //57.900> 1.5 enter: Freewind //58.008> 1.5 handle: Jack //58.009> 1.5 err: myerr //58.009> 1.5 results: [ undefined, 'Mike!!!' ] //58.208> 1.5 handle: Freewind //58.208> 1.5 enter: Test //58.273> 1.5 handle: Test