I know that when a Lambda function fails (for example when there is a time out), it tries to run the function 3 more times again. Is there any way to avoid this behavior? I\
Use below code to identify and stop retry when there is a failure.
exports.handler = (event, context, callback) => {
context.callbackWaitsForEmptyEventLoop = false;
let lastReqId;
if (lastReqId == context.awsRequestId) {
console.log("Lambda auto retry detected. Aborting");// you can write your own logic to decide what to do with the failure data
return context.succeed();
} else {
console.log("new context");
lastReqId = context.awsRequestId;
}
};
you can read more about it here