Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@smithy/middleware-retry

Package Overview
Dependencies
Maintainers
2
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/middleware-retry

[![NPM version](https://img.shields.io/npm/v/@smithy/middleware-retry/latest.svg)](https://www.npmjs.com/package/@smithy/middleware-retry) [![NPM downloads](https://img.shields.io/npm/dm/@smithy/middleware-retry.svg)](https://www.npmjs.com/package/@smithy

  • 3.0.28
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17M
increased by4.81%
Maintainers
2
Weekly downloads
 
Created

What is @smithy/middleware-retry?

@smithy/middleware-retry is a middleware package for the AWS SDK for JavaScript (v3) that provides retry functionality. It allows you to automatically retry failed requests based on customizable retry strategies, which can help improve the reliability and resilience of your applications.

What are @smithy/middleware-retry's main functionalities?

Standard Retry Strategy

The StandardRetryStrategy provides a default retry strategy that retries failed requests with exponential backoff and jitter. This is useful for handling transient errors and improving the reliability of your application.

const { StandardRetryStrategy } = require('@smithy/middleware-retry');
const retryStrategy = new StandardRetryStrategy();

// Use the retry strategy in a client configuration
const client = new SomeAWSClient({
  region: 'us-west-2',
  retryStrategy
});

Custom Retry Strategy

You can create a custom retry strategy by extending the RetryStrategy class and implementing your own logic for determining when to retry and how many attempts to make. This allows you to tailor the retry behavior to your specific needs.

const { RetryStrategy } = require('@smithy/middleware-retry');

class CustomRetryStrategy extends RetryStrategy {
  shouldRetry(error) {
    // Custom logic to determine if the request should be retried
    return error.retryable;
  }

  getMaxAttempts() {
    // Custom logic to determine the maximum number of retry attempts
    return 5;
  }
}

const customRetryStrategy = new CustomRetryStrategy();

// Use the custom retry strategy in a client configuration
const client = new SomeAWSClient({
  region: 'us-west-2',
  retryStrategy: customRetryStrategy
});

Adaptive Retry Strategy

The AdaptiveRetryStrategy dynamically adjusts the retry behavior based on the observed success and failure rates of requests. This can help optimize the retry behavior for different network conditions and improve overall performance.

const { AdaptiveRetryStrategy } = require('@smithy/middleware-retry');
const adaptiveRetryStrategy = new AdaptiveRetryStrategy();

// Use the adaptive retry strategy in a client configuration
const client = new SomeAWSClient({
  region: 'us-west-2',
  retryStrategy: adaptiveRetryStrategy
});

Other packages similar to @smithy/middleware-retry

FAQs

Package last updated on 21 Nov 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc