Closed
Description
Async 2.0.1, Node v0.10.29.
detectSeries on a large array causes a stack overflow even if the callbacks are called via setImmediate. Test case:
const async = require('async');
var arr = [];
for (var i = 0; i < 10000; i++) {
arr.push(i);
}
// this should print 0, then print done, because the detection succeeds on the
// first element of arr. It does, but then it causes a stack overflow
async.detectSeries(arr, function(data, cb) {
console.log(data);
setImmediate(cb, null, true);
// cb(null, true) is definitely expected to cause a stack overflow
// but setImmediate does not appear to change the situation
}, function(err, result) {
console.log("done");
});
What did you expect to happen?
0
done
What was the actual result?
0
done
.../node_modules/async/dist/async.js:843
return function () {
^
RangeError: Maximum call stack size exceeded
The bug appears to be tied to the size of arr. arr with 1000 items does not trigger the issue on my system.