Skip to main content


Middleware for handling partially failed SQS batches.


To install this middleware you can use NPM:

npm install --save @middy/sqs-partial-batch-failure
# Required for types only
npm install --save-dev @aws-sdk/client-sqs


  • logger (function) (optional): A function that will be called when a record fails to be processed. Default: console.error

Sample usage

import middy from '@middy/core'
import sqsBatch from '@middy/sqs-partial-batch-failure'

const lambdaHandler = (event, context) => {
const recordPromises = (record, index) => {
/* Custom message processing logic */
return record
return Promise.allSettled(recordPromises)

export const handler = middy().use(sqsBatch()).handler(lambdaHandler)


The value ReportBatchItemFailures must be added to your Lambda's FunctionResponseTypes in the EventSourceMapping. See Reporting batch item failures and Lambda EventSourceMapping