-1

I am using node js to get the HTTPS response from the server . The response contains more than 6291556 bytes When I execute this function I got the below exception. Is there any best way to handle the error

{
  "errorMessage": "Response payload size exceeded the maximum allowed payload size (6291556 bytes).",
  "errorType": "Function.ResponseSizeTooLarge"
}

Sample code

var res = await beResult(event.id);
    
      const response = {
          statusCode: 200,
          body: res,
      };
      return response;
    };
    
    async function beResult(id) {
      const url = "https://api.com/request/";    
      const params = {
          method: "GET",
          mode: "cors",
          headers: {
          "Access-Control-Allow-Methods": "GET, POST, OPTIONS",
          "Content-Type": "application/json",
          }
      };
      const urlId= url + id;
      return await fetch(urlId, params).then(res => res.json())
      .then(json => { return json;});
    }

1 Answers1

1

AWS Lambda functions have restrictions on the request and response size.

You can read about them on the Lambda quotas page of the developer guide.

Invocation payload (request and response)

  • 6 MB (synchronous)
  • 256 KB (asynchronous)
Mark Sailes
  • 727
  • 4
  • 16