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 個月前檢視次數 280 次
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!

您尚未登入。 登入 去張貼答案。

一個好的回答可以清楚地回答問題並提供建設性的意見回饋,同時有助於提問者的專業成長。

回答問題指南