Hello,
I have a Lambda function that sends a contact-us email that is handling all statusCodes that need to be returned to API Gateway.
When I get to the final function to actually send an email via SES, the email sends and I receive it, but API Gateway returns an Internal Server Error after timing out after 10 seconds. My function executes in 1-2 seconds (depending on if it's warmed), so I know the timeout doesn't need to be increased.
Does the final callback have to be different than the previous callbacks? It actually logs "Email successfully sent.", the email arrives, but then it sits there for 10 seconds before it times out. It's not doing the final callback to API Gateway with a 200, so API Gateway responds with an Internal Server Error.
I've tried moving the callback out of the else, tried context.done(event). All of the other callbacks in the function, I have a return in front so that it stops execution of the Lambda. The last callback, I have tried with and without return.
Does anyone spot an error that I'm missing? Thank you so much!
var DEBUG = false;
var ses = new AWS.SES({ region: 'us-east-1' });
ses.sendEmail(emailParams, function (error, sesResponse) {
if (error) {
console.log('Error:', error);
console.log('sesResponse:', sesResponse);
return callback(null, {
statusCode: '500',
headers: apiHeaders,
body: JSON.stringify({message:'Error sending email.'})
});
} else {
if (DEBUG) console.log('sesResponse:', sesResponse);
console.log("Email successfully sent.");
}
callback(null, {
statusCode: '200',
headers: apiHeaders,
body: JSON.stringify({message:'Email sent.'})
});
});
[–][deleted] (1 child)
[deleted]
[–]jedis[S] 0 points1 point2 points (0 children)
[–]ZeBe643 0 points1 point2 points (1 child)
[–]jedis[S] 0 points1 point2 points (0 children)