- Newest
- Most votes
- Most comments
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.
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.
Relevant content
- Accepted Answerasked 2 years ago
- asked a year ago
- AWS OFFICIALUpdated 9 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a month ago
- AWS OFFICIALUpdated 2 months ago
Maybe a better question is, how do I return a "Bad request" error in nodejs, the sort that won't get retried?