开发者社区> 镜像站> NPM> @perform/lambda-powertools-middleware-stop-infinite-loop
@perform/lambda-powertools-middleware-stop-infinite-loop

Middy middleware that detects and stops infinite loops

Moved to @dazn/lambda-powertools-middleware-stop-infinite-loop - please migrate to the new package by Tuesday 20th August 2019 as this package will be made private.
Last updated a year ago by automation-drone .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install @perform/lambda-powertools-middleware-stop-infinite-loop 
SYNC missed versions from official npm registry.

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 @perform/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 @perform/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 @perform/lambda-powertools-middleware-correlation-ids, it needs to be applied AFTER @perform/lambda-powertools-middleware-correlation-ids (as seen below).

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

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

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

Current Tags

  • 1.8.0                                ...           latest (a year ago)

4 Versions

  • 1.8.0 [deprecated]           ...           a year ago
  • 1.5.0 [deprecated]           ...           a year ago
  • 1.4.1 [deprecated]           ...           a year ago
  • 1.4.0 [deprecated]           ...           a year ago
Maintainers (325)
Downloads
Today 0
This Week 1
This Month 1
Last Day 0
Last Week 0
Last Month 0
Dev Dependencies (1)
Dependents (0)
None