Cognito PreSignup lambda is triggered multiple times at once

0

Hi all, I'm dealing with a frustrating problem with Cognito that feels like a bug to me.

Every so often, maybe every 50 signups or so, our PreSignup lambda is triggered 2 or sometimes even 3 times in a row, and each call happens within ~50 milliseconds of each other. Because of what our PreSignup trigger is doing, we cannot have 2+ signup requests for the same user running at the same time. This usually results in them running into each other -- its essentially like a race condition.

I've been searching online for a solution, the typical answer is that the lambda function is taking longer than the 5 second timeout to respond, but I'm certain this is not the issue because 1) the calls are happening within less than 5 seconds of each other and 2) my function takes a maximum of 3 seconds to respond.

I would like to take this up with AWS themselves because it feels like a bug in their systems to me, but I shouldn't have to pay $29 to open a case and report this bug!!!

1 Answer
0
Accepted Answer

Hello!

Currently, there are no service incident reports related to this. Could you please check the Lambda function logs and find Duration and Init Duration values for the function executions you describe?

As you have read, this happens when the function invocation fails, or the execution takes more than 5 seconds. Lambda will then retry two times.

If you have not done it already, check the sections Optimizing static initialization and Memory and computing power here, to optimize your function execution times.

Finally, when running logic like yours, my recommendation would be to always add idempotency.

profile pictureAWS
answered a month ago
  • Thank you for your response! I had no idea about the Init Duration - adding that to the Duration, the execution time does appear closer to 5 seconds. I've upgraded the AWS js SDK from v2 to v3 to hopefully optimize the performance. Hopefully that will work. Thank you!

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions