Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
@smithy/middleware-retry
Advanced tools
[![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
@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.
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
});
axios-retry is a plugin for the Axios HTTP client that adds automatic retry functionality. It allows you to configure retry strategies, including exponential backoff and custom retry logic. Compared to @smithy/middleware-retry, axios-retry is designed specifically for use with Axios and may not offer the same level of integration with AWS SDK for JavaScript (v3).
retry is a general-purpose retry library for JavaScript that provides a flexible API for implementing retry logic. It supports various retry strategies, including exponential backoff and custom retry logic. While it is not specifically designed for use with the AWS SDK, it can be used to implement retry functionality in a wide range of applications.
promise-retry is a library that provides retry functionality for promise-based operations. It allows you to configure retry strategies and handle transient errors in asynchronous code. Like retry, it is a general-purpose library and can be used in various contexts, but it does not offer the same level of integration with the AWS SDK as @smithy/middleware-retry.
See @smithy/util-retry for retry behavior and configuration.
See also: AWS Documentation: Retry behavior.
FAQs
[![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
The npm package @smithy/middleware-retry receives a total of 13,811,299 weekly downloads. As such, @smithy/middleware-retry popularity was classified as popular.
We found that @smithy/middleware-retry demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
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.
Security News
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.