Js throwing heap space error while json.stringify operation

Not applicable

My proxy receives a json input which provides multiple reference numbers. Using Javascripts I do asynchronous calls to a system which returns base 64 encoded pdf for each reference number. I use Js Mashup concept. The system sends data in a xml format.

After collecting all the base 64 encoded pdf data from the response xml of each reference number, I have to create a json request with the pdf data and post it to target backend. This is done in another java script since I have iterative logics and transformation while building the json request.

Whenever payload is more than 10mb due to big pdf files, json.stringify operation takes lot of time and the Javascript get timeout. Also It throws java heap space issue.

I understand the concept of streaming but I don't know whether it is implementable in this scenario. I am having the Js which creates the payload to target at the proxy eNDpoint request flow.

Can anyone provide a solution on how to post the big json request to the target backend without any js timeout and faster processing.

0 1 488
1 REPLY 1

@PRAVEENKUMAR SUTRAYE PREMKUMAR ,

I believe it's expected due to payload size restrictions. Message payload size is restricted to the 10 MB in Edge cloud.. Exceeding those sizes results in a protocol.http.TooBigBody error & other errors if you do same in JavaScript.

I would suggest you to use Node.JS to do async calls & payload processing. Give it a try using Apigee Node.JS container & let us know how it goes.