3.374.0 • Published 10 months ago

@aws-sdk/util-retry v3.374.0

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
10 months ago

@aws-sdk/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 @aws-sdk/util-retry.

import { S3Client } from "@aws-sdk/client-s3";
import { ConfiguredRetryStrategy } from "@aws-sdk/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 "@aws-sdk/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.

https://github.com/aws/aws-sdk-js-v3/blob/main/packages/types/src/retry.ts

3.364.0

10 months ago

3.369.0

10 months ago

3.370.0

10 months ago

3.374.0

10 months ago

3.347.0

11 months ago

3.342.0

11 months ago

3.362.0

10 months ago

3.357.0

11 months ago

3.327.0

1 year ago

3.341.0

12 months ago

3.337.0

12 months ago

3.338.0

12 months ago

3.329.0

1 year ago

3.310.0

1 year ago

3.306.0

1 year ago

3.303.0

1 year ago

3.266.0

1 year ago

3.296.0

1 year ago

3.295.0

1 year ago

3.289.0

1 year ago

3.267.0

1 year ago

3.266.1

1 year ago

3.290.0

1 year ago

3.292.0

1 year ago

3.271.0

1 year ago

3.272.0

1 year ago

3.254.0

1 year ago

3.257.0

1 year ago

3.229.0

1 year ago

3.226.0

1 year ago

3.224.0

1 year ago

3.222.0

1 year ago