0

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.

user3649361
  • 944
  • 4
  • 20
  • 40
  • _"will streaming the JSON data help"_. Possibly. Hard to tell without the code that you're using to query the database and send back the response. – robertklep Oct 17 '17 at 11:28
  • @robertklep I have added the bit of code to explain the issue. – user3649361 Oct 17 '17 at 11:45
  • It's going to be difficult to stream if you need to send back a complex object. In that case, you may have to limit the amount of data that you're sending back (and use paging, perhaps). – robertklep Oct 17 '17 at 11:58

0 Answers0