Soap RangeError: Maximum call stack size exceeded.

212 views
Skip to first unread message

Cocis

unread,
Jul 4, 2015, 11:02:09 PM7/4/15
to nod...@googlegroups.com
I have spent many many hours trying to resolve the issue with the following code to no avail:

var prettyjson = require('prettyjson');
soap = require('soap');

// Main initiator for SOAP client to web service
soap.createClient(url, function (err, client) {
    client.addSoapHeader(soapHeader); // Adds the <AccessToken><TokenValue> to header.
        client.GetInfo(args, function (err, result) {            // call SOAP service for parent information
                 console.log(prettyjson.render(result));        // logs information from parent via result as expected
                 serviceId = result[0].serviceID;
                 client.GetChildInfo(serviceId, function (err, result) {          // Nested call to SOAP service with callback to get the child record associated to parent (Surely this is not too deep)
                        console.log(prettyjson.render(result));   // This line throws the range error.
                 });
        });
});



I am using the module soap obtained via "npm install soap"

I cannot understand why this error is being thrown. I have searched the web high and low but have had to admit defeat and now seek assistance.


Am I doing something fundamentally wrong?
I am new to node.js and slowly wrapping my head arounf the none blocking event driven architecture. Slowly being the operative word given
my apparent difficulty with what seems a simple block of code above.


Any help greatfully appreciated.

Cocis

unread,
Jul 5, 2015, 2:14:03 PM7/5/15
to nod...@googlegroups.com

Solved.

It appears the call to prettyjson.render   was simply too much for the stack size.
Works perfectly when replaced with "JSON.stringify(result);"

Only took me about 10+ hours to figure that out!

Peter Rust

unread,
Jul 6, 2015, 2:03:25 PM7/6/15
to nod...@googlegroups.com
Cocis, thanks for sharing what the problem was! FWIW even JSON.stringify() can throw "Maximum call stack size exceeded", though I've never had to deal with JSON that was that heavily nested. One of the pouchDB guys wrote a module (https://github.com/nolanlawson/vuvuzela) to parse & stringify JSON in a non-recursive way to work around this problem.
Reply all
Reply to author
Forward
0 new messages