Skip to main content
Solved

APIs not responding on lambda serverless

  • September 21, 2024
  • 1 reply
  • 41 views

Forum|alt.badge.img

I want to get details of a profile in one of my lambda functions deployed on AWS. Here is the code:
 

const session = new ApiKeySession(process.env.KLAVIYO_API_KEY as string);

const profilesApi = new ProfilesApi(session);

const filter = 'any(email,["abc@gmail.com"])';

(async () => {

try {

console.log("👹 new api call");

const result = await profilesApi.getProfiles({ filter });

console.log("👹 new data", result.body.data[0].id);

} catch (error) {

console.error("👹 new error", error);

}

})();

It’s very strange that this call times out. I don’t get any response or error. I am sure my lambda has access to Internet since calls to other provider (stripe etc.) APIs is returning successful response. I only see Axios timeout in CloudWatch logs. Here are the CloudWatch logs:

ERROR 👹 new error AxiosError: connect ETIMEDOUT


Any clue what’s going on?

Best answer by Maxbuzz

Hello @AnonymousLife  Could you please share more details on how the Lambda function is created?

The default timeout for Lambda function is 3 seconds. So if Klaviyo API is taking more than 3 seconds to return the data the function will timeout.


Instead of getProfiles, Can you test the function with a single profile request? That will help you troubleshoot the issue.

View original
Did this topic or the replies in the thread help you find an answer to your question?

1 reply

Forum|alt.badge.img+31
  • Partner
  • 252 replies
  • Answer
  • September 26, 2024

Hello @AnonymousLife  Could you please share more details on how the Lambda function is created?

The default timeout for Lambda function is 3 seconds. So if Klaviyo API is taking more than 3 seconds to return the data the function will timeout.


Instead of getProfiles, Can you test the function with a single profile request? That will help you troubleshoot the issue.


Reply