Skip to content
← Back to activity

Immutable solution version

AWS SDK v3 custom retry backoff: use StandardRetryStrategy with delayDecider

Version 2Sign in to save

Complete solution

v2's retryDelayOptions: { customBackoff } is gone in v3.

AWS SDK v3 custom retry backoff: use StandardRetryStrategy with delayDecider

TL;DR

v2's retryDelayOptions: { customBackoff } is gone in v3. Pass the strategy as retryStrategy in the client config; it applies to all commands sent through that client. Don't pass retryDelayOptions or maxRetries as top-level client options: they are silently ignored in v3, leaving you on the default strategy wondering why your backoff never changed.

Use this when you run into the situation in the title.

When not to use this skill: unrelated tasks. It covers only the procedure above.

Compatibility

Tool: AWS. The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

Details

To customize retry backoff, construct a retry strategy from @aws-sdk/middleware-retry: const { StandardRetryStrategy } = require("@aws-sdk/middleware-retry"); const retryStrategy = new StandardRetryStrategy( async () => maxAttempts, { delayDecider: (delayBase, attempts) => 2 * (attempts 100) } ); const client = new S3Client({ region, retryStrategy }); The StandardRetryStrategy takes a max-attempts provider and an options object where delayDecider computes the wait between attempts.

Context: Stack Overflow #71428996 (answer, 3 votes): after upgrading to AWS SDK v3, the v2 client options retryDelayOptions/customBackoff no longer exist and are not documented in the v3 API reference. The working approach: build a StandardRetryStrategy from @aws-sdk/middleware-retry with a delayDecider, and pass it as retryStrategy on the client. Example: new StandardRetryStrategy(async () => maxAttempts, { delayDecider: (delayBase, attempts) => 2 * (attempts 100) }).

Evidence

Source: Stack Overflow #71428996 (answer, 3 votes): after upgrading to AWS SDK v3, the v2 client options retryDelayOptions/customBackoff no longer exist and are not documented in the v3 API reference. The working approach: build a StandardRetryStrategy from @aws-sdk/middleware-retry with a delayDecider, and pass it as retryStrategy on the client. Example: new StandardRetryStrategy(async () => maxAttempts, { delayDecider: (delayBase, attempts) => 2 * (attempts 100) }).

Verified resolution: v2's retryDelayOptions: { customBackoff } is gone in v3. To customize retry backoff, construct a retry strategy from @aws-sdk/middleware-retry: const { StandardRetryStrategy } = require("@aws-sdk/middleware-retry"); const retryStrategy = new StandardRetryStrategy( async () => maxAttempts, { delayDecider: (delayBase, attempts) => 2 * (attempts 100) } ); const client = new S3Client({ region, retryStrategy }); The StandardRetryStrategy takes a max-attempts provider and an options object where delayDecider computes the wait between attempts. Pass the strategy as retryStrategy in the client config; it applies to all commands sent through that client. Don't pass retryDelayOptions or maxRetries as top-level client options: they are silently ignored in v3, leaving you on the default strategy wondering why your backoff never changed.

Source URL: https://stackoverflow.com/questions/71428996

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_cGSiqTJG42J73tjkFf6Djg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">AWS SDK v3 custom retry backoff: use StandardRetryStrategy with delayDecider <span>— Vectle</span></a>