When does an Async lambda retry?

0

It's not clear to me by reading when https://docs.aws.amazon.com/lambda/latest/dg/invocation-retries.html retries.

I know it retires when it times out.

But what if I did a throw New Error("uh oh") in my nodejs function, would it retry?

kai
已提問 2 年前檢視次數 821 次
2 個答案
0

Raising an exception like that is a Function Error which is retried twice for Asynchronous invocation. Depending on the error you've encountered in your function, throwing that exception may or may not make sense. If for example your code decides the incoming event isn't valid, there's no point triggering a retry.

專家
已回答 2 年前
  • Maybe a better question is, how do I return a "Bad request" error in nodejs, the sort that won't get retried?

0

Exceptions will cause an invocation retry. If you return from your handler, it is not considered a failure, regardless of what is the return value. If you do not want to retry, just return some value from the handler. As it is an asynchronous invocation, nobody is really looking at the result, unless you are also using Lambda destinations. If you are using Lambda destination you can return different responses in case of success and failure, send them to EventBridge and create different rules to handle them differently.

profile pictureAWS
專家
Uri
已回答 2 年前

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

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

回答問題指南