Error Handling

Sync

  • Handle it using the source service, such SQS DLQ

Handle errors using SQS

  • Lambda will reprocess the entire message batch (try - fail - put it back - try - fail - put it back ...) until
      1. Successful
      1. Message is deleted due to retention period, or deleted manually
      1. maxReceiveCount is reached
      The maxReceiveCount is the number of times a consumer tries receiving a message from a queue without deleting it before being moved to the dead-letter queue.
  • Configure a DLQ
💡
Lambda will retry the entire batch even though there is only one bad message.

Async

  • Triggered by
  • By default, retry 2 times (0~2) with maximum age of event (6 hours by default) between each retry
    • Retry 2 more times by default
    • 1-minute wait time between 1st and 2nd
    • 2-minute wait time between 2nd and 3rd
  • Set on-failure destination, such as SQS, SNS, Lambda, and EventBridge
  • Dead letter queue
However, a dead-letter queue is part of a function's version-specific configuration, so it is locked in when you publish a version. On-failure destinations also support additional targets and include details about the function's response in the invocation record.