What is @aws-sdk/middleware-recursion-detection?
@aws-sdk/middleware-recursion-detection is a middleware package for the AWS SDK for JavaScript. It helps in detecting and preventing recursive calls in AWS SDK clients, which can be useful in avoiding infinite loops and ensuring the stability of your application.
Recursion Detection Middleware
This feature allows you to add recursion detection middleware to an AWS SDK client. The middleware helps in detecting recursive calls and prevents potential infinite loops.
const { S3Client } = require('@aws-sdk/client-s3');
const { recursionDetectionMiddleware } = require('@aws-sdk/middleware-recursion-detection');
const client = new S3Client({});
client.middlewareStack.add(recursionDetectionMiddleware, {
step: 'initialize',
name: 'recursionDetectionMiddleware',
tags: ['RECURSION_DETECTION'],
});
// Now you can use the client with recursion detection enabled
client.send(new ListBucketsCommand({}));