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!!!

已提问 2 个月前281 查看次数
1 回答
0
已接受的回答

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
已回答 2 个月前
  • 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!

您未登录。 登录 发布回答。

一个好的回答可以清楚地解答问题和提供建设性反馈,并能促进提问者的职业发展。

回答问题的准则