Bruno Faria
Bruno Faria

Reputation: 5272

Maximum call stack size exceeded using async.queue

i'm running the code below but i'm getting stack size exceeded and i can´t figure why. The code works fine for fewer items (tested with up to 1000). When i try with a larger number of items i always get this error. I'm using the Parse sdk btw.

d:\GitHub\ExampleProj\node_modules\parse\build\parse-latest.js:785
    each(slice.call(arguments, 1), function(source) {
               ^
RangeError: Maximum call stack size exceeded

Any ideas? here's a clean version of the code

var q = async.queue(function (user, callback) {
    user.signUp(null, {
        success: function(user) {
            callback();
        },
        error: function(user, error) {
            callback();
        }
    });
}, 100);

q.drain = function() {
    console.log('All items have been processed');
};

// ~17000 items
for(var i=0; i < sqlFiles.length; i++) {
    var user = {
        ...
    };

    q.push(user);
}

Upvotes: 3

Views: 1393

Answers (1)

Andrew Surzhynskyi
Andrew Surzhynskyi

Reputation: 2776

node stack size is similar to stack size in browser with v8 engine, it's like 25 000. But you can use a console param to increase it:

node --stack-size=1000000000 file.js

Upvotes: 5

Related Questions