1.29.0 • Published 3 years ago

@dazn/lambda-powertools-middleware-stop-infinite-loop v1.29.0

Weekly downloads
644
License
MIT
Repository
github
Last release
3 years ago

lambda-powertools-middleware-stop-infinite-loop

A Middy middleware that will stop an invocation if it's deemed to be part of an infinite loop.

Main features:

  • errors if the call-chain-length reaches the configured threshold (defaults to 10)

Getting Started

Install from NPM: npm install @dazn/lambda-powertools-middleware-stop-infinite-loop

API

The middleware accepts an optional constructor parameter threshold, which is the max length allowed for the entire call chain.

This middleware is intended to be used alongside @dazn/lambda-powertools-middleware-correlation-ids, which is responsible for collecting correlation IDs and incrementing the call-chain-length (i.e. the number of function invocations that are chained together) at the start of an invocation.

Because this middleware relies on @dazn/lambda-powertools-middleware-correlation-ids, it needs to be applied AFTER @dazn/lambda-powertools-middleware-correlation-ids (as seen below).

const middy = require('middy')
const correlationIds = require('@dazn/lambda-powertools-middleware-correlation-ids')
const stopInfiniteLoop = require('@dazn/lambda-powertools-middleware-stop-infinite-loop')

const handler = async (event, context) => {
  return 42
}

module.exports = middy(handler)
  .use(correlationIds())
  .use(stopInfiniteLoop()) // defaults to 10
}
1.29.0

3 years ago

1.28.1

3 years ago

1.28.0

3 years ago

1.24.1

4 years ago

1.24.0

4 years ago

1.23.2

4 years ago

1.23.1

4 years ago

1.23.0

4 years ago

1.22.1

4 years ago

1.22.0

4 years ago

1.21.1

4 years ago

1.21.0

4 years ago

1.15.2

5 years ago

1.9.0

5 years ago

1.8.2

5 years ago

1.8.0

5 years ago