When the NodeJS Lambda will be retired with type Event Source Stream-based (Ex: DynamoDB, SQS)?
When the lambda will retry: AWS will trigger the Lambda functions again until they’re returned successfully or the data expires, and Your lambda execution will block the event source until in finished
Without Stream-Based events, you can configure the batch record and number of retries some configuration
MaximumRetryAttempts: Discard records after the specified number of retries.
BatchSize: The maximum number of records in each batch that Lambda pulls from your stream or queue and sends to your function. Lambda passes all of the records in the batch to the function in a single call, up to the payload limit for synchronous invocation (6 MB).
Default value: Varies by service. For Amazon SQS, the default is 10. For all other services, the default is 100.
Related setting: When you set BatchSize
to a value greater than 10, you must set MaximumBatchingWindowInSeconds
it to at least 1.
In case, if the lambda throws an error, the entire batch is reprocessed until it was run successfully, or until all messages in the event source ( queue, streams) expired. link
NodeJS Lambda make the lambda retry use cases
#1 Using the callback to return an error
#2 The lambda throws an error
#3 Promise.Reject catch the error with callback
#4 Try-catch and throw error