I've have the same question as earlier but having trouble relating the answers to my code. Here's my error: RangeError: Maximum call stack size exceeded
.
The highly simplified pseudo version of my code is this:
function make_request(url, other_params){
request(url, function(response){
if(something) var some_var = 'some value';
else var some_var = '';
//do something with response to generate, some_var, and insert into DB
var my_arr = [some_var];
connection.query('INSERT my_table SET name = ?', my_arr, function(err, rows, fields) {
if(my_arr==''){
// generate new url to make new request
make_request(url, other_params);
}
});
});
}
connection.query('SELECT * from my_table', function(err, rows, fields){
var len =rows.length;
for(var i = 0; i < len; i++){
var url = rows[i].url;
make_request(url, other_params);
}
});
I've tried wrapping the internal make_request
in setImmediate
or setTimeout
amongst a few other hacks, but nothing seems to prevent the call stack error. I'm able to add any library that would make this work. Any thoughts would be appreciated.