Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aws-sdk/middleware-retry

Package Overview
Dependencies
Maintainers
5
Versions
151
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aws-sdk/middleware-retry - npm Package Compare versions

Comparing version 3.168.0 to 3.169.0

11

CHANGELOG.md

@@ -6,2 +6,13 @@ # Change Log

# [3.169.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.168.0...v3.169.0) (2022-09-12)
### Bug Fixes
* **middleware-retry:** use delay from response header if it's higher ([#3916](https://github.com/aws/aws-sdk-js-v3/issues/3916)) ([9524fa1](https://github.com/aws/aws-sdk-js-v3/commit/9524fa1a515262b5692e326dd1db25966f146941))
# [3.168.0](https://github.com/aws/aws-sdk-js-v3/compare/v3.167.0...v3.168.0) (2022-09-09)

@@ -8,0 +19,0 @@

17

dist-cjs/StandardRetryStrategy.js

@@ -65,3 +65,5 @@ "use strict";

retryTokenAmount = this.retryQuota.retrieveRetryTokens(err);
const delay = this.delayDecider((0, service_error_classification_1.isThrottlingError)(err) ? constants_1.THROTTLING_RETRY_DELAY_BASE : constants_1.DEFAULT_RETRY_DELAY_BASE, attempts);
const delayFromDecider = this.delayDecider((0, service_error_classification_1.isThrottlingError)(err) ? constants_1.THROTTLING_RETRY_DELAY_BASE : constants_1.DEFAULT_RETRY_DELAY_BASE, attempts);
const delayFromResponse = getDelayFromRetryAfterHeader(err.$response);
const delay = Math.max(delayFromResponse || 0, delayFromDecider);
totalDelay += delay;

@@ -82,2 +84,15 @@ await new Promise((resolve) => setTimeout(resolve, delay));

exports.StandardRetryStrategy = StandardRetryStrategy;
const getDelayFromRetryAfterHeader = (response) => {
if (!protocol_http_1.HttpResponse.isInstance(response))
return;
const retryAfterHeaderName = Object.keys(response.headers).find((key) => key.toLowerCase() === "retry-after");
if (!retryAfterHeaderName)
return;
const retryAfter = response.headers[retryAfterHeaderName];
const retryAfterSeconds = Number(retryAfter);
if (!Number.isNaN(retryAfterSeconds))
return retryAfterSeconds * 1000;
const retryAfterDate = new Date(retryAfter);
return retryAfterDate.getTime() - Date.now();
};
const asSdkError = (error) => {

@@ -84,0 +99,0 @@ if (error instanceof Error)

import { __awaiter, __generator } from "tslib";
import { HttpRequest } from "@aws-sdk/protocol-http";
import { HttpRequest, HttpResponse } from "@aws-sdk/protocol-http";
import { isThrottlingError } from "@aws-sdk/service-error-classification";

@@ -58,3 +58,3 @@ import { v4 } from "uuid";

_loop_1 = function () {
var _b, response, output, e_1, err, delay_1;
var _b, response, output, e_1, err, delayFromDecider, delayFromResponse, delay_1;
return __generator(this, function (_c) {

@@ -88,3 +88,5 @@ switch (_c.label) {

retryTokenAmount = this_1.retryQuota.retrieveRetryTokens(err);
delay_1 = this_1.delayDecider(isThrottlingError(err) ? THROTTLING_RETRY_DELAY_BASE : DEFAULT_RETRY_DELAY_BASE, attempts);
delayFromDecider = this_1.delayDecider(isThrottlingError(err) ? THROTTLING_RETRY_DELAY_BASE : DEFAULT_RETRY_DELAY_BASE, attempts);
delayFromResponse = getDelayFromRetryAfterHeader(err.$response);
delay_1 = Math.max(delayFromResponse || 0, delayFromDecider);
totalDelay += delay_1;

@@ -124,2 +126,15 @@ return [4, new Promise(function (resolve) { return setTimeout(resolve, delay_1); })];

export { StandardRetryStrategy };
var getDelayFromRetryAfterHeader = function (response) {
if (!HttpResponse.isInstance(response))
return;
var retryAfterHeaderName = Object.keys(response.headers).find(function (key) { return key.toLowerCase() === "retry-after"; });
if (!retryAfterHeaderName)
return;
var retryAfter = response.headers[retryAfterHeaderName];
var retryAfterSeconds = Number(retryAfter);
if (!Number.isNaN(retryAfterSeconds))
return retryAfterSeconds * 1000;
var retryAfterDate = new Date(retryAfter);
return retryAfterDate.getTime() - Date.now();
};
var asSdkError = function (error) {

@@ -126,0 +141,0 @@ if (error instanceof Error)

2

package.json
{
"name": "@aws-sdk/middleware-retry",
"version": "3.168.0",
"version": "3.169.0",
"scripts": {

@@ -5,0 +5,0 @@ "build": "concurrently 'yarn:build:cjs' 'yarn:build:es' 'yarn:build:types'",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc