async.eachSeries RangeError:超出最大调用堆栈大小

时间:2015-10-15 17:09:30

标签: node.js asynchronous cryptojs

我在node.js v0.10.33上使用async@0.9.0运行此操作,尝试测试crypto.createCipher但最终收到错误:RangeError: Maximum call stack size exceeded

/**
 * New node file
 */
var crypto = require('crypto');
var async = require('async');
var _ = require('underscore');

var l = [];
var o = [];
for (var i=0; i<4899; i++) {
    l.push(String(i));
}

var key = 'mykey';
var algorithm = 'aes256';

async.eachSeries(l, function(item, callback) {
    var cipher = crypto.createCipher(algorithm, key);
    var encrypted = cipher.update(item, 'utf8', 'hex') + cipher.final('hex');
    var decipher = crypto.createDecipher(algorithm, key);
    var decrypted = decipher.update(encrypted, 'hex', 'utf8') + decipher.final('utf8');
    o.push(encrypted);
    callback(null);
}, function(err) {
    console.log('err', err, 'o', o.length, 'o-uniq', _.uniq(o).length)
    var le = _.map(o, function(i) {
        return i.length
    })
    console.log('le', le.length, 'le-uniq', _.uniq(le).length, le[0])
})

错误堆栈:

node.js:896
    var fn = runInThisContext(source, this.filename, true);
             ^
RangeError: Maximum call stack size exceeded

0 个答案:

没有答案