@smithy/util-retry
Shared retry utilities to be used in middleware packages.
Last updated a month ago by smithy-team .
Apache-2.0 · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @smithy/util-retry 
SYNC missed versions from official npm registry.

@smithy/util-retry

NPM version NPM downloads

This package provides shared utilities for retries.

Usage

Default

By default, each client already has a default retry strategy. The default retry count is 3, and only retryable errors will be retried.

AWS Documentation: Retry behavior.

import { S3Client } from "@aws-sdk/client-s3";

const client = new S3Client({}); // default retry strategy included.

MaxAttempts

If you want to change the number of attempts, you can provide maxAttempts configuration during client creation.

import { S3Client } from "@aws-sdk/client-s3";

const client = new S3Client({ maxAttempts: 4 });

This is recommended because the StandardRetryStrategy includes backoff calculation, deciding whether an error should be retried, and a retry token counter.

MaxAttempts and BackoffComputation

If you want to change the number of attempts and use a custom delay computation, you can use the ConfiguredRetryStrategy from @smithy/util-retry.

import { S3Client } from "@aws-sdk/client-s3";
import { ConfiguredRetryStrategy } from "@smithy/util-retry";

const client = new S3Client({
  retryStrategy: new ConfiguredRetryStrategy(
    4, // max attempts.
    (attempt: number) => 100 + attempt * 1000 // backoff function.
  ),
});

This example sets the backoff at 100ms plus 1s per attempt.

MaxAttempts and RetryStrategy

If you provide both maxAttempts and retryStrategy, the retryStrategy will get precedence as it's more specific.

import { S3Client } from "@aws-sdk/client-s3";
import { ConfiguredRetryStrategy } from "@smithy/util-retry";

const client = new S3Client({
  maxAttempts: 2, // ignored.
  retryStrategy: new ConfiguredRetryStrategy(
    4, // used.
    (attempt: number) => 100 + attempt * 1000 // backoff function.
  ),
});

Further customization

You can implement the RetryStrategyV2 interface.

Source: https://github.com/awslabs/smithy-typescript/blob/main/packages/types/src/retry.ts API Docs: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-smithy-types/Interface/RetryStrategyV2/

Current Tags

  • 3.0.10                                ...           latest (a month ago)

33 Versions

  • 3.0.10                                ...           a month ago
  • 3.0.9                                ...           a month ago
  • 3.0.8                                ...           2 months ago
  • 3.0.7                                ...           3 months ago
  • 3.0.6                                ...           3 months ago
  • 3.0.5                                ...           3 months ago
  • 3.0.4                                ...           4 months ago
  • 3.0.3                                ...           6 months ago
  • 3.0.2                                ...           6 months ago
  • 3.0.1                                ...           6 months ago
  • 3.0.0                                ...           7 months ago
  • 2.2.0                                ...           9 months ago
  • 2.1.4                                ...           10 months ago
  • 2.1.3                                ...           10 months ago
  • 2.1.2                                ...           10 months ago
  • 2.1.1                                ...           a year ago
  • 2.1.0                                ...           a year ago
  • 2.0.9                                ...           a year ago
  • 2.0.8                                ...           a year ago
  • 2.0.7                                ...           a year ago
  • 2.0.6                                ...           a year ago
  • 2.0.5                                ...           a year ago
  • 2.0.4                                ...           a year ago
  • 2.0.3                                ...           a year ago
  • 2.0.2                                ...           a year ago
  • 2.0.1                                ...           a year ago
  • 2.0.0                                ...           a year ago
  • 1.1.0                                ...           a year ago
  • 1.0.4                                ...           a year ago
  • 1.0.3                                ...           a year ago
  • 1.0.2                                ...           a year ago
  • 1.0.1                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
Downloads
Total 2
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (3)
Dev Dependencies (5)

© 2010 - cnpmjs.org x YWFE | Home | YWFE