@smithy/middleware-retry 4.1.22 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/index.js +33 -47
- package/dist-types/AdaptiveRetryStrategy.d.ts +4 -3
- package/dist-types/StandardRetryStrategy.d.ts +2 -2
- package/dist-types/configurations.d.ts +2 -2
- package/dist-types/defaultRetryQuota.d.ts +1 -1
- package/dist-types/omitRetryHeadersMiddleware.d.ts +1 -1
- package/dist-types/retryDecider.d.ts +1 -1
- package/dist-types/retryMiddleware.d.ts +2 -2
- package/dist-types/ts3.4/AdaptiveRetryStrategy.d.ts +2 -1
- package/dist-types/types.d.ts +1 -1
- package/dist-types/util.d.ts +1 -1
- package/package.json +9 -8
package/dist-cjs/index.js
CHANGED
|
@@ -18,8 +18,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
|
|
20
20
|
// src/index.ts
|
|
21
|
-
var
|
|
22
|
-
__export(
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
23
|
AdaptiveRetryStrategy: () => AdaptiveRetryStrategy,
|
|
24
24
|
CONFIG_MAX_ATTEMPTS: () => CONFIG_MAX_ATTEMPTS,
|
|
25
25
|
CONFIG_RETRY_MODE: () => CONFIG_RETRY_MODE,
|
|
@@ -39,7 +39,7 @@ __export(src_exports, {
|
|
|
39
39
|
retryMiddleware: () => retryMiddleware,
|
|
40
40
|
retryMiddlewareOptions: () => retryMiddlewareOptions
|
|
41
41
|
});
|
|
42
|
-
module.exports = __toCommonJS(
|
|
42
|
+
module.exports = __toCommonJS(index_exports);
|
|
43
43
|
|
|
44
44
|
// src/AdaptiveRetryStrategy.ts
|
|
45
45
|
|
|
@@ -94,12 +94,9 @@ var defaultRetryDecider = /* @__PURE__ */ __name((error) => {
|
|
|
94
94
|
|
|
95
95
|
// src/util.ts
|
|
96
96
|
var asSdkError = /* @__PURE__ */ __name((error) => {
|
|
97
|
-
if (error instanceof Error)
|
|
98
|
-
|
|
99
|
-
if (error
|
|
100
|
-
return Object.assign(new Error(), error);
|
|
101
|
-
if (typeof error === "string")
|
|
102
|
-
return new Error(error);
|
|
97
|
+
if (error instanceof Error) return error;
|
|
98
|
+
if (error instanceof Object) return Object.assign(new Error(), error);
|
|
99
|
+
if (typeof error === "string") return new Error(error);
|
|
103
100
|
return new Error(`AWS SDK error wrapper for ${error}`);
|
|
104
101
|
}, "asSdkError");
|
|
105
102
|
|
|
@@ -178,15 +175,12 @@ var StandardRetryStrategy = class {
|
|
|
178
175
|
}
|
|
179
176
|
};
|
|
180
177
|
var getDelayFromRetryAfterHeader = /* @__PURE__ */ __name((response) => {
|
|
181
|
-
if (!import_protocol_http.HttpResponse.isInstance(response))
|
|
182
|
-
return;
|
|
178
|
+
if (!import_protocol_http.HttpResponse.isInstance(response)) return;
|
|
183
179
|
const retryAfterHeaderName = Object.keys(response.headers).find((key) => key.toLowerCase() === "retry-after");
|
|
184
|
-
if (!retryAfterHeaderName)
|
|
185
|
-
return;
|
|
180
|
+
if (!retryAfterHeaderName) return;
|
|
186
181
|
const retryAfter = response.headers[retryAfterHeaderName];
|
|
187
182
|
const retryAfterSeconds = Number(retryAfter);
|
|
188
|
-
if (!Number.isNaN(retryAfterSeconds))
|
|
189
|
-
return retryAfterSeconds * 1e3;
|
|
183
|
+
if (!Number.isNaN(retryAfterSeconds)) return retryAfterSeconds * 1e3;
|
|
190
184
|
const retryAfterDate = new Date(retryAfter);
|
|
191
185
|
return retryAfterDate.getTime() - Date.now();
|
|
192
186
|
}, "getDelayFromRetryAfterHeader");
|
|
@@ -204,12 +198,12 @@ var AdaptiveRetryStrategy = class extends StandardRetryStrategy {
|
|
|
204
198
|
}
|
|
205
199
|
async retry(next, args) {
|
|
206
200
|
return super.retry(next, args, {
|
|
207
|
-
beforeRequest: async () => {
|
|
201
|
+
beforeRequest: /* @__PURE__ */ __name(async () => {
|
|
208
202
|
return this.rateLimiter.getSendToken();
|
|
209
|
-
},
|
|
210
|
-
afterRequest: (response) => {
|
|
203
|
+
}, "beforeRequest"),
|
|
204
|
+
afterRequest: /* @__PURE__ */ __name((response) => {
|
|
211
205
|
this.rateLimiter.updateClientSendingRate(response);
|
|
212
|
-
}
|
|
206
|
+
}, "afterRequest")
|
|
213
207
|
});
|
|
214
208
|
}
|
|
215
209
|
};
|
|
@@ -220,26 +214,24 @@ var import_util_middleware = require("@smithy/util-middleware");
|
|
|
220
214
|
var ENV_MAX_ATTEMPTS = "AWS_MAX_ATTEMPTS";
|
|
221
215
|
var CONFIG_MAX_ATTEMPTS = "max_attempts";
|
|
222
216
|
var NODE_MAX_ATTEMPT_CONFIG_OPTIONS = {
|
|
223
|
-
environmentVariableSelector: (env) => {
|
|
217
|
+
environmentVariableSelector: /* @__PURE__ */ __name((env) => {
|
|
224
218
|
const value = env[ENV_MAX_ATTEMPTS];
|
|
225
|
-
if (!value)
|
|
226
|
-
return void 0;
|
|
219
|
+
if (!value) return void 0;
|
|
227
220
|
const maxAttempt = parseInt(value);
|
|
228
221
|
if (Number.isNaN(maxAttempt)) {
|
|
229
222
|
throw new Error(`Environment variable ${ENV_MAX_ATTEMPTS} mast be a number, got "${value}"`);
|
|
230
223
|
}
|
|
231
224
|
return maxAttempt;
|
|
232
|
-
},
|
|
233
|
-
configFileSelector: (profile) => {
|
|
225
|
+
}, "environmentVariableSelector"),
|
|
226
|
+
configFileSelector: /* @__PURE__ */ __name((profile) => {
|
|
234
227
|
const value = profile[CONFIG_MAX_ATTEMPTS];
|
|
235
|
-
if (!value)
|
|
236
|
-
return void 0;
|
|
228
|
+
if (!value) return void 0;
|
|
237
229
|
const maxAttempt = parseInt(value);
|
|
238
230
|
if (Number.isNaN(maxAttempt)) {
|
|
239
231
|
throw new Error(`Shared config file entry ${CONFIG_MAX_ATTEMPTS} mast be a number, got "${value}"`);
|
|
240
232
|
}
|
|
241
233
|
return maxAttempt;
|
|
242
|
-
},
|
|
234
|
+
}, "configFileSelector"),
|
|
243
235
|
default: import_util_retry.DEFAULT_MAX_ATTEMPTS
|
|
244
236
|
};
|
|
245
237
|
var resolveRetryConfig = /* @__PURE__ */ __name((input) => {
|
|
@@ -247,7 +239,7 @@ var resolveRetryConfig = /* @__PURE__ */ __name((input) => {
|
|
|
247
239
|
const maxAttempts = (0, import_util_middleware.normalizeProvider)(_maxAttempts ?? import_util_retry.DEFAULT_MAX_ATTEMPTS);
|
|
248
240
|
return Object.assign(input, {
|
|
249
241
|
maxAttempts,
|
|
250
|
-
retryStrategy: async () => {
|
|
242
|
+
retryStrategy: /* @__PURE__ */ __name(async () => {
|
|
251
243
|
if (retryStrategy) {
|
|
252
244
|
return retryStrategy;
|
|
253
245
|
}
|
|
@@ -256,14 +248,14 @@ var resolveRetryConfig = /* @__PURE__ */ __name((input) => {
|
|
|
256
248
|
return new import_util_retry.AdaptiveRetryStrategy(maxAttempts);
|
|
257
249
|
}
|
|
258
250
|
return new import_util_retry.StandardRetryStrategy(maxAttempts);
|
|
259
|
-
}
|
|
251
|
+
}, "retryStrategy")
|
|
260
252
|
});
|
|
261
253
|
}, "resolveRetryConfig");
|
|
262
254
|
var ENV_RETRY_MODE = "AWS_RETRY_MODE";
|
|
263
255
|
var CONFIG_RETRY_MODE = "retry_mode";
|
|
264
256
|
var NODE_RETRY_MODE_CONFIG_OPTIONS = {
|
|
265
|
-
environmentVariableSelector: (env) => env[ENV_RETRY_MODE],
|
|
266
|
-
configFileSelector: (profile) => profile[CONFIG_RETRY_MODE],
|
|
257
|
+
environmentVariableSelector: /* @__PURE__ */ __name((env) => env[ENV_RETRY_MODE], "environmentVariableSelector"),
|
|
258
|
+
configFileSelector: /* @__PURE__ */ __name((profile) => profile[CONFIG_RETRY_MODE], "configFileSelector"),
|
|
267
259
|
default: import_util_retry.DEFAULT_RETRY_MODE
|
|
268
260
|
};
|
|
269
261
|
|
|
@@ -286,9 +278,9 @@ var omitRetryHeadersMiddlewareOptions = {
|
|
|
286
278
|
override: true
|
|
287
279
|
};
|
|
288
280
|
var getOmitRetryHeadersPlugin = /* @__PURE__ */ __name((options) => ({
|
|
289
|
-
applyToStack: (clientStack) => {
|
|
281
|
+
applyToStack: /* @__PURE__ */ __name((clientStack) => {
|
|
290
282
|
clientStack.addRelativeTo(omitRetryHeadersMiddleware(), omitRetryHeadersMiddlewareOptions);
|
|
291
|
-
}
|
|
283
|
+
}, "applyToStack")
|
|
292
284
|
}), "getOmitRetryHeadersPlugin");
|
|
293
285
|
|
|
294
286
|
// src/retryMiddleware.ts
|
|
@@ -367,12 +359,9 @@ var getRetryErrorInfo = /* @__PURE__ */ __name((error) => {
|
|
|
367
359
|
return errorInfo;
|
|
368
360
|
}, "getRetryErrorInfo");
|
|
369
361
|
var getRetryErrorType = /* @__PURE__ */ __name((error) => {
|
|
370
|
-
if ((0, import_service_error_classification.isThrottlingError)(error))
|
|
371
|
-
|
|
372
|
-
if ((0, import_service_error_classification.
|
|
373
|
-
return "TRANSIENT";
|
|
374
|
-
if ((0, import_service_error_classification.isServerError)(error))
|
|
375
|
-
return "SERVER_ERROR";
|
|
362
|
+
if ((0, import_service_error_classification.isThrottlingError)(error)) return "THROTTLING";
|
|
363
|
+
if ((0, import_service_error_classification.isTransientError)(error)) return "TRANSIENT";
|
|
364
|
+
if ((0, import_service_error_classification.isServerError)(error)) return "SERVER_ERROR";
|
|
376
365
|
return "CLIENT_ERROR";
|
|
377
366
|
}, "getRetryErrorType");
|
|
378
367
|
var retryMiddlewareOptions = {
|
|
@@ -383,20 +372,17 @@ var retryMiddlewareOptions = {
|
|
|
383
372
|
override: true
|
|
384
373
|
};
|
|
385
374
|
var getRetryPlugin = /* @__PURE__ */ __name((options) => ({
|
|
386
|
-
applyToStack: (clientStack) => {
|
|
375
|
+
applyToStack: /* @__PURE__ */ __name((clientStack) => {
|
|
387
376
|
clientStack.add(retryMiddleware(options), retryMiddlewareOptions);
|
|
388
|
-
}
|
|
377
|
+
}, "applyToStack")
|
|
389
378
|
}), "getRetryPlugin");
|
|
390
379
|
var getRetryAfterHint = /* @__PURE__ */ __name((response) => {
|
|
391
|
-
if (!import_protocol_http.HttpResponse.isInstance(response))
|
|
392
|
-
return;
|
|
380
|
+
if (!import_protocol_http.HttpResponse.isInstance(response)) return;
|
|
393
381
|
const retryAfterHeaderName = Object.keys(response.headers).find((key) => key.toLowerCase() === "retry-after");
|
|
394
|
-
if (!retryAfterHeaderName)
|
|
395
|
-
return;
|
|
382
|
+
if (!retryAfterHeaderName) return;
|
|
396
383
|
const retryAfter = response.headers[retryAfterHeaderName];
|
|
397
384
|
const retryAfterSeconds = Number(retryAfter);
|
|
398
|
-
if (!Number.isNaN(retryAfterSeconds))
|
|
399
|
-
return new Date(retryAfterSeconds * 1e3);
|
|
385
|
+
if (!Number.isNaN(retryAfterSeconds)) return new Date(retryAfterSeconds * 1e3);
|
|
400
386
|
const retryAfterDate = new Date(retryAfter);
|
|
401
387
|
return retryAfterDate;
|
|
402
388
|
}, "getRetryAfterHint");
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { FinalizeHandler, FinalizeHandlerArguments, MetadataBearer, Provider } from "@smithy/types";
|
|
2
|
-
import { RateLimiter } from "@smithy/util-retry";
|
|
3
|
-
import {
|
|
1
|
+
import type { FinalizeHandler, FinalizeHandlerArguments, MetadataBearer, Provider } from "@smithy/types";
|
|
2
|
+
import type { RateLimiter } from "@smithy/util-retry";
|
|
3
|
+
import type { StandardRetryStrategyOptions } from "./StandardRetryStrategy";
|
|
4
|
+
import { StandardRetryStrategy } from "./StandardRetryStrategy";
|
|
4
5
|
/**
|
|
5
6
|
* @public
|
|
6
7
|
* Strategy options to be passed to AdaptiveRetryStrategy
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FinalizeHandler, FinalizeHandlerArguments, MetadataBearer, Provider, RetryStrategy } from "@smithy/types";
|
|
2
|
-
import { DelayDecider, RetryDecider, RetryQuota } from "./types";
|
|
1
|
+
import type { FinalizeHandler, FinalizeHandlerArguments, MetadataBearer, Provider, RetryStrategy } from "@smithy/types";
|
|
2
|
+
import type { DelayDecider, RetryDecider, RetryQuota } from "./types";
|
|
3
3
|
/**
|
|
4
4
|
* Strategy options to be passed to StandardRetryStrategy
|
|
5
5
|
* @public
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { LoadedConfigSelectors } from "@smithy/node-config-provider";
|
|
2
|
-
import { Provider, RetryStrategy, RetryStrategyV2 } from "@smithy/types";
|
|
1
|
+
import type { LoadedConfigSelectors } from "@smithy/node-config-provider";
|
|
2
|
+
import type { Provider, RetryStrategy, RetryStrategyV2 } from "@smithy/types";
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AbsoluteLocation, FinalizeHandler, FinalizeRequestHandlerOptions, HandlerExecutionContext, MetadataBearer, Pluggable } from "@smithy/types";
|
|
2
|
-
import { RetryResolvedConfig } from "./configurations";
|
|
1
|
+
import type { AbsoluteLocation, FinalizeHandler, FinalizeRequestHandlerOptions, HandlerExecutionContext, MetadataBearer, Pluggable } from "@smithy/types";
|
|
2
|
+
import type { RetryResolvedConfig } from "./configurations";
|
|
3
3
|
/**
|
|
4
4
|
* @internal
|
|
5
5
|
*/
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { FinalizeHandler, FinalizeHandlerArguments, MetadataBearer, Provider } from "@smithy/types";
|
|
2
2
|
import { RateLimiter } from "@smithy/util-retry";
|
|
3
|
-
import {
|
|
3
|
+
import { StandardRetryStrategyOptions } from "./StandardRetryStrategy";
|
|
4
|
+
import { StandardRetryStrategy } from "./StandardRetryStrategy";
|
|
4
5
|
/**
|
|
5
6
|
* @public
|
|
6
7
|
* Strategy options to be passed to AdaptiveRetryStrategy
|
package/dist-types/types.d.ts
CHANGED
package/dist-types/util.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SdkError } from "@smithy/types";
|
|
1
|
+
import type { SdkError } from "@smithy/types";
|
|
2
2
|
export declare const asSdkError: (error: unknown) => SdkError;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/middleware-retry",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.2.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types && yarn build:types:downlevel'",
|
|
6
6
|
"build:cjs": "node ../../scripts/inline middleware-retry",
|
|
@@ -32,14 +32,15 @@
|
|
|
32
32
|
"url": "https://aws.amazon.com/javascript/"
|
|
33
33
|
},
|
|
34
34
|
"license": "Apache-2.0",
|
|
35
|
+
"sideEffects": false,
|
|
35
36
|
"dependencies": {
|
|
36
|
-
"@smithy/node-config-provider": "^4.
|
|
37
|
-
"@smithy/protocol-http": "^5.
|
|
38
|
-
"@smithy/service-error-classification": "^4.0
|
|
39
|
-
"@smithy/smithy-client": "^4.
|
|
40
|
-
"@smithy/types": "^4.
|
|
41
|
-
"@smithy/util-middleware": "^4.0
|
|
42
|
-
"@smithy/util-retry": "^4.0
|
|
37
|
+
"@smithy/node-config-provider": "^4.2.0",
|
|
38
|
+
"@smithy/protocol-http": "^5.2.0",
|
|
39
|
+
"@smithy/service-error-classification": "^4.1.0",
|
|
40
|
+
"@smithy/smithy-client": "^4.6.0",
|
|
41
|
+
"@smithy/types": "^4.4.0",
|
|
42
|
+
"@smithy/util-middleware": "^4.1.0",
|
|
43
|
+
"@smithy/util-retry": "^4.1.0",
|
|
43
44
|
"@types/uuid": "^9.0.1",
|
|
44
45
|
"tslib": "^2.6.2",
|
|
45
46
|
"uuid": "^9.0.1"
|