I am querying the database and sending the response to the UI, res.json, when I query database for large data, I get
FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
I got this
and -max_old_space_size=2000000
is working fine but I don't want to use it as the app will be used by many people in different system, Is there any other way I can solve it.
will streaming the JSON data help or any other way in which it can be done.
var onDataEvent = dataStream.on('data', function (row) {
dataRows.push(row);
});
var onDataEndEvent = dataStream.on('end', function () {
dataBody.DATA = dataRows;
res.json(repapiResponseBody);
});
I am getting the database response stream from the database and converting it to json object(because I might need to transform the response based not the request parameter) and sending the response.