@smithy/middleware-retry
Advanced tools
Comparing version 2.0.21 to 2.0.22
@@ -6,6 +6,9 @@ "use strict"; | ||
const service_error_classification_1 = require("@smithy/service-error-classification"); | ||
const smithy_client_1 = require("@smithy/smithy-client"); | ||
const util_retry_1 = require("@smithy/util-retry"); | ||
const uuid_1 = require("uuid"); | ||
const isStreamingPayload_1 = require("./isStreamingPayload/isStreamingPayload"); | ||
const util_1 = require("./util"); | ||
const retryMiddleware = (options) => (next, context) => async (args) => { | ||
var _a; | ||
let retryStrategy = await options.retryStrategy(); | ||
@@ -20,3 +23,4 @@ const maxAttempts = await options.maxAttempts(); | ||
const { request } = args; | ||
if (protocol_http_1.HttpRequest.isInstance(request)) { | ||
const isRequest = protocol_http_1.HttpRequest.isInstance(request); | ||
if (isRequest) { | ||
request.headers[util_retry_1.INVOCATION_ID_HEADER] = (0, uuid_1.v4)(); | ||
@@ -26,3 +30,3 @@ } | ||
try { | ||
if (protocol_http_1.HttpRequest.isInstance(request)) { | ||
if (isRequest) { | ||
request.headers[util_retry_1.REQUEST_HEADER] = `attempt=${attempts + 1}; max=${maxAttempts}`; | ||
@@ -39,2 +43,6 @@ } | ||
lastError = (0, util_1.asSdkError)(e); | ||
if (isRequest && (0, isStreamingPayload_1.isStreamingPayload)(request)) { | ||
(_a = (context.logger instanceof smithy_client_1.NoOpLogger ? console : context.logger)) === null || _a === void 0 ? void 0 : _a.warn("An error was encountered in a non-retryable streaming request."); | ||
throw lastError; | ||
} | ||
try { | ||
@@ -41,0 +49,0 @@ retryToken = await retryStrategy.refreshRetryTokenForRetry(retryToken, retryErrorInfo); |
import { HttpRequest, HttpResponse } from "@smithy/protocol-http"; | ||
import { isServerError, isThrottlingError, isTransientError } from "@smithy/service-error-classification"; | ||
import { NoOpLogger } from "@smithy/smithy-client"; | ||
import { INVOCATION_ID_HEADER, REQUEST_HEADER } from "@smithy/util-retry"; | ||
import { v4 } from "uuid"; | ||
import { isStreamingPayload } from "./isStreamingPayload/isStreamingPayload"; | ||
import { asSdkError } from "./util"; | ||
@@ -16,3 +18,4 @@ export const retryMiddleware = (options) => (next, context) => async (args) => { | ||
const { request } = args; | ||
if (HttpRequest.isInstance(request)) { | ||
const isRequest = HttpRequest.isInstance(request); | ||
if (isRequest) { | ||
request.headers[INVOCATION_ID_HEADER] = v4(); | ||
@@ -22,3 +25,3 @@ } | ||
try { | ||
if (HttpRequest.isInstance(request)) { | ||
if (isRequest) { | ||
request.headers[REQUEST_HEADER] = `attempt=${attempts + 1}; max=${maxAttempts}`; | ||
@@ -35,2 +38,6 @@ } | ||
lastError = asSdkError(e); | ||
if (isRequest && isStreamingPayload(request)) { | ||
(context.logger instanceof NoOpLogger ? console : context.logger)?.warn("An error was encountered in a non-retryable streaming request."); | ||
throw lastError; | ||
} | ||
try { | ||
@@ -37,0 +44,0 @@ retryToken = await retryStrategy.refreshRetryTokenForRetry(retryToken, retryErrorInfo); |
{ | ||
"name": "@smithy/middleware-retry", | ||
"version": "2.0.21", | ||
"version": "2.0.22", | ||
"scripts": { | ||
@@ -11,3 +11,3 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'", | ||
"stage-release": "rimraf ./.release && yarn pack && mkdir ./.release && tar zxvf ./package.tgz --directory ./.release && rm ./package.tgz", | ||
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo", | ||
"clean": "rimraf ./dist-* && rimraf *.tsbuildinfo || exit 0", | ||
"lint": "eslint -c ../../.eslintrc.js \"src/**/*.ts\"", | ||
@@ -22,2 +22,9 @@ "format": "prettier --config ../../prettier.config.js --ignore-path ../.prettierignore --write \"**/*.{ts,md,json}\"", | ||
"types": "./dist-types/index.d.ts", | ||
"browser": { | ||
"./dist-es/isStreamingPayload/isStreamingPayload": "./dist-es/isStreamingPayload/isStreamingPayload.browser" | ||
}, | ||
"react-native": { | ||
"./dist-cjs/isStreamingPayload/isStreamingPayload": "./dist-cjs/isStreamingPayload/isStreamingPayload.browser", | ||
"./dist-es/isStreamingPayload/isStreamingPayload": "./dist-es/isStreamingPayload/isStreamingPayload.browser" | ||
}, | ||
"author": { | ||
@@ -29,8 +36,9 @@ "name": "AWS SDK for JavaScript Team", | ||
"dependencies": { | ||
"@smithy/node-config-provider": "^2.1.6", | ||
"@smithy/protocol-http": "^3.0.10", | ||
"@smithy/service-error-classification": "^2.0.7", | ||
"@smithy/types": "^2.6.0", | ||
"@smithy/util-middleware": "^2.0.7", | ||
"@smithy/util-retry": "^2.0.7", | ||
"@smithy/node-config-provider": "^2.1.7", | ||
"@smithy/protocol-http": "^3.0.11", | ||
"@smithy/service-error-classification": "^2.0.8", | ||
"@smithy/smithy-client": "^2.1.17", | ||
"@smithy/types": "^2.7.0", | ||
"@smithy/util-middleware": "^2.0.8", | ||
"@smithy/util-retry": "^2.0.8", | ||
"tslib": "^2.5.0", | ||
@@ -40,3 +48,3 @@ "uuid": "^8.3.2" | ||
"devDependencies": { | ||
"@smithy/util-test": "^0.1.10", | ||
"@smithy/util-test": "^0.1.11", | ||
"@tsconfig/recommended": "1.0.1", | ||
@@ -43,0 +51,0 @@ "@types/uuid": "^8.3.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
66201
55
1151
9
2
+ Added@smithy/abort-controller@2.2.0(transitive)
+ Added@smithy/fetch-http-handler@2.5.0(transitive)
+ Added@smithy/is-array-buffer@2.2.0(transitive)
+ Added@smithy/middleware-endpoint@2.5.1(transitive)
+ Added@smithy/middleware-serde@2.3.0(transitive)
+ Added@smithy/middleware-stack@2.2.0(transitive)
+ Added@smithy/node-http-handler@2.5.0(transitive)
+ Added@smithy/querystring-builder@2.2.0(transitive)
+ Added@smithy/querystring-parser@2.2.0(transitive)
+ Added@smithy/smithy-client@2.5.1(transitive)
+ Added@smithy/url-parser@2.2.0(transitive)
+ Added@smithy/util-base64@2.3.0(transitive)
+ Added@smithy/util-buffer-from@2.2.0(transitive)
+ Added@smithy/util-hex-encoding@2.2.0(transitive)
+ Added@smithy/util-stream@2.2.0(transitive)
+ Added@smithy/util-uri-escape@2.2.0(transitive)
+ Added@smithy/util-utf8@2.3.0(transitive)
Updated@smithy/types@^2.7.0
Updated@smithy/util-retry@^2.0.8