Skip to content

Conversation

mltucker
Copy link

async.eachSeries causes stack overflows for large lists.

process.version; // => "v0.10.4"
var async = require("async");
var _ = require("underscore");

var count = 0;
async.eachSeries(_.range(10000), function(n, callback) {
    count += n;
    callback();
}, function(err) {
    console.log(count);
});

Before:

RangeError: Maximum call stack size exceeded

After:

49995000

This fixes stack overflows on large lists in node.js.
@diversario
Copy link

Having the same issue with stack overflow.

@boutell
Copy link
Contributor

boutell commented May 20, 2013

Whoops, I opened a duplicate issue and sent a duplicate pull request on this, so count me in as well.

@dougwilson
Copy link
Contributor

The module is meant to call async functions. Your

function(n, callback) {
    count += n;
    callback();
}

is not async, thus incompatible.

@caolan
Copy link
Owner

caolan commented Jan 23, 2014

Yes, making functions asynchronous is left up to the developer

@caolan caolan closed this Jan 23, 2014
@boutell
Copy link
Contributor

boutell commented Jan 23, 2014

OK, I understand that logic. There's a performance penalty imposed by each call to setImmediate too, so it would be redundant extra slowness for functions that are already asynchronous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants