{"name":"@smithy/util-retry","version":"4.0.0","keywords":["aws","retry"],"author":{"url":"https://aws.amazon.com/javascript/","name":"AWS SDK for JavaScript Team"},"license":"Apache-2.0","_id":"@smithy/util-retry@4.0.0","homepage":"https://github.com/awslabs/smithy-typescript/tree/master/packages/util-retry","bugs":{"url":"https://github.com/awslabs/smithy-typescript/issues"},"dist":{"shasum":"c08f1894278afce4ab3c00b55883f13026f04222","tarball":"http://registry-npm.ywwl.com/@smithy/util-retry/download/@smithy/util-retry-4.0.0.tgz","fileCount":43,"integrity":"sha512-64WFoC19NVuHh3HQO2QbGw+n6GzQ6VH/drxwXLOU3GDLKxUUzIR9XNm9aTVqh8/7R+y+DgITiv5LpX5XdOy73A==","signatures":[{"sig":"MEYCIQDC2jnpxXxzjQ1AzY13E7bFyH1KXIWOJlf9JBPAbLm5cAIhALCLRAmW0YTDgQHwQPuMSG5ZRd7lhOjR0i2szbsH3aDW","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":57177,"size":13812,"noattachment":false,"key":"/@smithy/util-retry/-/@smithy/util-retry-4.0.0.tgz"},"main":"./dist-cjs/index.js","types":"./dist-types/index.d.ts","module":"./dist-es/index.js","engines":{"node":">=18.0.0"},"gitHead":"de3a850552111a7018df855f808258074a90ab62","scripts":{"lint":"eslint -c ../../.eslintrc.js \"src/**/*.ts\"","test":"yarn g:vitest run","build":"concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'","clean":"rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0","format":"prettier --config ../../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\"","build:es":"yarn g:tsc -p tsconfig.es.json","build:cjs":"node ../../scripts/inline util-retry","test:watch":"yarn g:vitest watch","build:types":"yarn g:tsc -p tsconfig.types.json","extract:docs":"api-extractor run --local","stage-release":"rimraf ./.release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz","build:types:downlevel":"rimraf dist-types/ts3.4 && downlevel-dts dist-types dist-types/ts3.4"},"typedoc":{"entryPoint":"src/index.ts"},"_npmUser":{"name":"smithy-team","email":"aws-smithy-team+npm@amazon.com"},"repository":{"url":"git+https://github.com/awslabs/smithy-typescript.git","type":"git","directory":"packages/util-retry"},"_npmVersion":"10.8.2","description":"Shared retry utilities to be used in middleware packages.","directories":{},"_nodeVersion":"18.20.5","dependencies":{"tslib":"^2.6.2","@smithy/types":"^4.0.0","@smithy/service-error-classification":"^4.0.0"},"publishConfig":{"directory":".release/package"},"typesVersions":{"<4.0":{"types/*":["types/ts3.4/*"]}},"_hasShrinkwrap":false,"devDependencies":{"rimraf":"3.0.2","typedoc":"0.23.23","@types/node":"^18.11.9","concurrently":"7.0.0","downlevel-dts":"0.10.1"},"_npmOperationalInternal":{"tmp":"tmp/util-retry_4.0.0_1736185164234_0.03591487803135274","host":"s3://npm-registry-packages-npm-production"},"readme":"# @smithy/util-retry\n\n[![NPM version](https://img.shields.io/npm/v/@smithy/util-retry/latest.svg)](https://www.npmjs.com/package/@smithy/util-retry)\n[![NPM downloads](https://img.shields.io/npm/dm/@smithy/util-retry.svg)](https://www.npmjs.com/package/@smithy/util-retry)\n\nThis package provides shared utilities for retries.\n\n## Usage\n\n### Default\n\nBy default, each client already has a default retry strategy. The default retry count is 3, and\nonly retryable errors will be retried.\n\n[AWS Documentation: Retry behavior](https://docs.aws.amazon.com/sdkref/latest/guide/feature-retry-behavior.html).\n\n```js\nimport { S3Client } from \"@aws-sdk/client-s3\";\n\nconst client = new S3Client({}); // default retry strategy included.\n```\n\n### MaxAttempts\n\nIf you want to change the number of attempts, you can provide `maxAttempts` configuration during client creation.\n\n```js\nimport { S3Client } from \"@aws-sdk/client-s3\";\n\nconst client = new S3Client({ maxAttempts: 4 });\n```\n\nThis is recommended because the `StandardRetryStrategy` includes backoff calculation,\ndeciding whether an error should be retried, and a retry token counter.\n\n### MaxAttempts and BackoffComputation\n\nIf you want to change the number of attempts and use a custom delay\ncomputation, you can use the `ConfiguredRetryStrategy` from `@smithy/util-retry`.\n\n```js\nimport { S3Client } from \"@aws-sdk/client-s3\";\nimport { ConfiguredRetryStrategy } from \"@smithy/util-retry\";\n\nconst client = new S3Client({\n  retryStrategy: new ConfiguredRetryStrategy(\n    4, // max attempts.\n    (attempt: number) => 100 + attempt * 1000 // backoff function.\n  ),\n});\n```\n\nThis example sets the backoff at 100ms plus 1s per attempt.\n\n### MaxAttempts and RetryStrategy\n\nIf you provide both `maxAttempts` and `retryStrategy`, the `retryStrategy` will\nget precedence as it's more specific.\n\n```js\nimport { S3Client } from \"@aws-sdk/client-s3\";\nimport { ConfiguredRetryStrategy } from \"@smithy/util-retry\";\n\nconst client = new S3Client({\n  maxAttempts: 2, // ignored.\n  retryStrategy: new ConfiguredRetryStrategy(\n    4, // used.\n    (attempt: number) => 100 + attempt * 1000 // backoff function.\n  ),\n});\n```\n\n### Further customization\n\nYou can implement the `RetryStrategyV2` interface.\n\nSource: https://github.com/awslabs/smithy-typescript/blob/main/packages/types/src/retry.ts\nAPI Docs: https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-smithy-types/Interface/RetryStrategyV2/\n","publish_time":1736185164611,"maintainers":[{"name":"trivikr-aws","email":"trivikr@amazon.com"},{"name":"smithy-team","email":"aws-smithy-team+npm@amazon.com"},{"name":"aws-sdk-bot","email":"aws-sdk-js-automation@amazon.com"}],"_cnpm_publish_time":1736185164611,"dist-tags":{"latest":"4.6.2"}}