Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@smithy/core

Package Overview
Dependencies
Maintainers
3
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@smithy/core - npm Package Compare versions

Comparing version
3.24.5
to
3.24.6
+39
-22
dist-cjs/submodules/retry/index.browser.js

@@ -36,3 +36,3 @@ 'use strict';

const NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "ECONNREFUSED", "EPIPE", "ETIMEDOUT"];
const NODEJS_NETWORK_ERROR_CODES = ["EHOSTUNREACH", "ENETUNREACH", "ENOTFOUND"];
const NODEJS_NETWORK_ERROR_CODES = ["EHOSTUNREACH", "ENETUNREACH", "ENOTFOUND", "EAI_AGAIN"];

@@ -188,5 +188,2 @@ const isRetryableByTrait = (error) => error?.$retryable !== undefined;

catch (refreshError) {
if (typeof refreshError.$backoff === "number") {
await cooldown(refreshError.$backoff);
}
if (!lastError.$metadata) {

@@ -201,4 +198,6 @@ lastError.$metadata = {};

const delay = retryToken.getRetryDelay();
totalRetryDelay += delay;
await cooldown(delay);
totalRetryDelay += (retryToken?.$retryLog?.acquisitionDelay ?? 0) + delay;
if (delay > 0) {
await cooldown(delay);
}
}

@@ -404,2 +403,5 @@ }

longPoll;
$retryLog = {
acquisitionDelay: 0,
};
constructor(delay, count, cost, longPoll) {

@@ -440,4 +442,4 @@ this.delay = delay;

mode = exports.RETRY_MODES.STANDARD;
retryBackoffStrategy;
capacity = INITIAL_RETRY_TOKENS;
retryBackoffStrategy;
maxAttemptsProvider;

@@ -478,5 +480,6 @@ baseDelay;

if (!shouldRetry) {
throw Object.assign(new Error("No retry token available"), {
$backoff: Retry.v2026 && retryCode === refusal.capacity && isLongPoll ? retryDelay : 0,
});
const longPollBackoff = Retry.v2026 && retryCode === refusal.capacity && isLongPoll ? retryDelay : 0;
if (longPollBackoff > 0) {
await new Promise((r) => setTimeout(r, longPollBackoff));
}
}

@@ -486,3 +489,6 @@ else {

this.capacity -= capacityCost;
return new DefaultRetryToken(retryDelay, token.getRetryCount() + 1, capacityCost, token.isLongPoll?.() ?? false);
const nextToken = new DefaultRetryToken(0, token.getRetryCount() + 1, capacityCost, token.isLongPoll?.() ?? false);
await new Promise((r) => setTimeout(r, retryDelay));
nextToken.$retryLog.acquisitionDelay = retryDelay;
return nextToken;
}

@@ -569,8 +575,7 @@ }

}
this.retryBackoffStrategy.computeNextBackoffDelay = (completedAttempt) => {
const nextAttempt = completedAttempt + 1;
return this.computeNextBackoffDelay(nextAttempt);
};
}
async refreshRetryTokenForRetry(tokenToRenew, errorInfo) {
const token = await super.refreshRetryTokenForRetry(tokenToRenew, errorInfo);
token.getRetryDelay = () => this.computeNextBackoffDelay(token.getRetryCount());
return token;
}
}

@@ -721,13 +726,25 @@

const resolveRetryConfig = (input) => {
const resolveRetryConfig = (input, defaults) => {
const { retryStrategy, retryMode } = input;
const maxAttempts = client.normalizeProvider(input.maxAttempts ?? DEFAULT_MAX_ATTEMPTS);
const { defaultMaxAttempts = DEFAULT_MAX_ATTEMPTS, defaultBaseDelay = Retry.delay() } = defaults ?? {};
const maxAttemptsProvider = client.normalizeProvider(input.maxAttempts ?? defaultMaxAttempts);
let controller = retryStrategy
? Promise.resolve(retryStrategy)
: undefined;
const getDefault = async () => (await client.normalizeProvider(retryMode)()) === exports.RETRY_MODES.ADAPTIVE
? new AdaptiveRetryStrategy$1(maxAttempts)
: new StandardRetryStrategy$1(maxAttempts);
const getDefault = async () => {
const maxAttempts = await maxAttemptsProvider();
const adaptive = (await client.normalizeProvider(retryMode)()) === exports.RETRY_MODES.ADAPTIVE;
if (adaptive) {
return new AdaptiveRetryStrategy$1(maxAttemptsProvider, {
maxAttempts,
baseDelay: defaultBaseDelay,
});
}
return new StandardRetryStrategy$1({
maxAttempts,
baseDelay: defaultBaseDelay,
});
};
return Object.assign(input, {
maxAttempts,
maxAttempts: maxAttemptsProvider,
retryStrategy: () => (controller ??= getDefault()),

@@ -734,0 +751,0 @@ });

@@ -38,3 +38,3 @@ 'use strict';

const NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "ECONNREFUSED", "EPIPE", "ETIMEDOUT"];
const NODEJS_NETWORK_ERROR_CODES = ["EHOSTUNREACH", "ENETUNREACH", "ENOTFOUND"];
const NODEJS_NETWORK_ERROR_CODES = ["EHOSTUNREACH", "ENETUNREACH", "ENOTFOUND", "EAI_AGAIN"];

@@ -190,5 +190,2 @@ const isRetryableByTrait = (error) => error?.$retryable !== undefined;

catch (refreshError) {
if (typeof refreshError.$backoff === "number") {
await cooldown(refreshError.$backoff);
}
if (!lastError.$metadata) {

@@ -203,4 +200,6 @@ lastError.$metadata = {};

const delay = retryToken.getRetryDelay();
totalRetryDelay += delay;
await cooldown(delay);
totalRetryDelay += (retryToken?.$retryLog?.acquisitionDelay ?? 0) + delay;
if (delay > 0) {
await cooldown(delay);
}
}

@@ -406,2 +405,5 @@ }

longPoll;
$retryLog = {
acquisitionDelay: 0,
};
constructor(delay, count, cost, longPoll) {

@@ -442,4 +444,4 @@ this.delay = delay;

mode = exports.RETRY_MODES.STANDARD;
retryBackoffStrategy;
capacity = INITIAL_RETRY_TOKENS;
retryBackoffStrategy;
maxAttemptsProvider;

@@ -480,5 +482,6 @@ baseDelay;

if (!shouldRetry) {
throw Object.assign(new Error("No retry token available"), {
$backoff: Retry.v2026 && retryCode === refusal.capacity && isLongPoll ? retryDelay : 0,
});
const longPollBackoff = Retry.v2026 && retryCode === refusal.capacity && isLongPoll ? retryDelay : 0;
if (longPollBackoff > 0) {
await new Promise((r) => setTimeout(r, longPollBackoff));
}
}

@@ -488,3 +491,6 @@ else {

this.capacity -= capacityCost;
return new DefaultRetryToken(retryDelay, token.getRetryCount() + 1, capacityCost, token.isLongPoll?.() ?? false);
const nextToken = new DefaultRetryToken(0, token.getRetryCount() + 1, capacityCost, token.isLongPoll?.() ?? false);
await new Promise((r) => setTimeout(r, retryDelay));
nextToken.$retryLog.acquisitionDelay = retryDelay;
return nextToken;
}

@@ -571,8 +577,7 @@ }

}
this.retryBackoffStrategy.computeNextBackoffDelay = (completedAttempt) => {
const nextAttempt = completedAttempt + 1;
return this.computeNextBackoffDelay(nextAttempt);
};
}
async refreshRetryTokenForRetry(tokenToRenew, errorInfo) {
const token = await super.refreshRetryTokenForRetry(tokenToRenew, errorInfo);
token.getRetryDelay = () => this.computeNextBackoffDelay(token.getRetryCount());
return token;
}
}

@@ -748,13 +753,25 @@

};
const resolveRetryConfig = (input) => {
const resolveRetryConfig = (input, defaults) => {
const { retryStrategy, retryMode } = input;
const maxAttempts = client.normalizeProvider(input.maxAttempts ?? DEFAULT_MAX_ATTEMPTS);
const { defaultMaxAttempts = DEFAULT_MAX_ATTEMPTS, defaultBaseDelay = Retry.delay() } = defaults ?? {};
const maxAttemptsProvider = client.normalizeProvider(input.maxAttempts ?? defaultMaxAttempts);
let controller = retryStrategy
? Promise.resolve(retryStrategy)
: undefined;
const getDefault = async () => (await client.normalizeProvider(retryMode)()) === exports.RETRY_MODES.ADAPTIVE
? new AdaptiveRetryStrategy$1(maxAttempts)
: new StandardRetryStrategy$1(maxAttempts);
const getDefault = async () => {
const maxAttempts = await maxAttemptsProvider();
const adaptive = (await client.normalizeProvider(retryMode)()) === exports.RETRY_MODES.ADAPTIVE;
if (adaptive) {
return new AdaptiveRetryStrategy$1(maxAttemptsProvider, {
maxAttempts,
baseDelay: defaultBaseDelay,
});
}
return new StandardRetryStrategy$1({
maxAttempts,
baseDelay: defaultBaseDelay,
});
};
return Object.assign(input, {
maxAttempts,
maxAttempts: maxAttemptsProvider,
retryStrategy: () => (controller ??= getDefault()),

@@ -761,0 +778,0 @@ });

@@ -5,2 +5,3 @@ import { normalizeProvider } from "@smithy/core/client";

import { DEFAULT_MAX_ATTEMPTS, DEFAULT_RETRY_MODE, RETRY_MODES } from "../util-retry/config";
import { Retry } from "../util-retry/retries-2026-config";
export const ENV_MAX_ATTEMPTS = "AWS_MAX_ATTEMPTS";

@@ -31,13 +32,25 @@ export const CONFIG_MAX_ATTEMPTS = "max_attempts";

};
export const resolveRetryConfig = (input) => {
export const resolveRetryConfig = (input, defaults) => {
const { retryStrategy, retryMode } = input;
const maxAttempts = normalizeProvider(input.maxAttempts ?? DEFAULT_MAX_ATTEMPTS);
const { defaultMaxAttempts = DEFAULT_MAX_ATTEMPTS, defaultBaseDelay = Retry.delay() } = defaults ?? {};
const maxAttemptsProvider = normalizeProvider(input.maxAttempts ?? defaultMaxAttempts);
let controller = retryStrategy
? Promise.resolve(retryStrategy)
: undefined;
const getDefault = async () => (await normalizeProvider(retryMode)()) === RETRY_MODES.ADAPTIVE
? new AdaptiveRetryStrategy(maxAttempts)
: new StandardRetryStrategy(maxAttempts);
const getDefault = async () => {
const maxAttempts = await maxAttemptsProvider();
const adaptive = (await normalizeProvider(retryMode)()) === RETRY_MODES.ADAPTIVE;
if (adaptive) {
return new AdaptiveRetryStrategy(maxAttemptsProvider, {
maxAttempts,
baseDelay: defaultBaseDelay,
});
}
return new StandardRetryStrategy({
maxAttempts,
baseDelay: defaultBaseDelay,
});
};
return Object.assign(input, {
maxAttempts,
maxAttempts: maxAttemptsProvider,
retryStrategy: () => (controller ??= getDefault()),

@@ -44,0 +57,0 @@ });

@@ -45,5 +45,2 @@ import { NoOpLogger } from "@smithy/core/client";

catch (refreshError) {
if (typeof refreshError.$backoff === "number") {
await cooldown(refreshError.$backoff);
}
if (!lastError.$metadata) {

@@ -58,4 +55,6 @@ lastError.$metadata = {};

const delay = retryToken.getRetryDelay();
totalRetryDelay += delay;
await cooldown(delay);
totalRetryDelay += (retryToken?.$retryLog?.acquisitionDelay ?? 0) + delay;
if (delay > 0) {
await cooldown(delay);
}
}

@@ -62,0 +61,0 @@ }

@@ -28,2 +28,2 @@ export const CLOCK_SKEW_ERROR_CODES = [

export const NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "ECONNREFUSED", "EPIPE", "ETIMEDOUT"];
export const NODEJS_NETWORK_ERROR_CODES = ["EHOSTUNREACH", "ENETUNREACH", "ENOTFOUND"];
export const NODEJS_NETWORK_ERROR_CODES = ["EHOSTUNREACH", "ENETUNREACH", "ENOTFOUND", "EAI_AGAIN"];

@@ -13,8 +13,7 @@ import { StandardRetryStrategy } from "./StandardRetryStrategy";

}
this.retryBackoffStrategy.computeNextBackoffDelay = (completedAttempt) => {
const nextAttempt = completedAttempt + 1;
return this.computeNextBackoffDelay(nextAttempt);
};
}
async refreshRetryTokenForRetry(tokenToRenew, errorInfo) {
const token = await super.refreshRetryTokenForRetry(tokenToRenew, errorInfo);
token.getRetryDelay = () => this.computeNextBackoffDelay(token.getRetryCount());
return token;
}
}

@@ -7,2 +7,5 @@ import { MAXIMUM_RETRY_DELAY } from "./constants";

longPoll;
$retryLog = {
acquisitionDelay: 0,
};
constructor(delay, count, cost, longPoll) {

@@ -9,0 +12,0 @@ this.delay = delay;

@@ -13,4 +13,4 @@ import { DefaultRetryBackoffStrategy } from "./DefaultRetryBackoffStrategy";

mode = RETRY_MODES.STANDARD;
retryBackoffStrategy;
capacity = INITIAL_RETRY_TOKENS;
retryBackoffStrategy;
maxAttemptsProvider;

@@ -51,5 +51,6 @@ baseDelay;

if (!shouldRetry) {
throw Object.assign(new Error("No retry token available"), {
$backoff: Retry.v2026 && retryCode === refusal.capacity && isLongPoll ? retryDelay : 0,
});
const longPollBackoff = Retry.v2026 && retryCode === refusal.capacity && isLongPoll ? retryDelay : 0;
if (longPollBackoff > 0) {
await new Promise((r) => setTimeout(r, longPollBackoff));
}
}

@@ -59,3 +60,6 @@ else {

this.capacity -= capacityCost;
return new DefaultRetryToken(retryDelay, token.getRetryCount() + 1, capacityCost, token.isLongPoll?.() ?? false);
const nextToken = new DefaultRetryToken(0, token.getRetryCount() + 1, capacityCost, token.isLongPoll?.() ?? false);
await new Promise((r) => setTimeout(r, retryDelay));
nextToken.$retryLog.acquisitionDelay = retryDelay;
return nextToken;
}

@@ -62,0 +66,0 @@ }

@@ -56,3 +56,6 @@ import type { LoadedConfigSelectors } from "@smithy/core/config";

*/
export declare const resolveRetryConfig: <T>(input: T & PreviouslyResolved & RetryInputConfig) => T & RetryResolvedConfig;
export declare const resolveRetryConfig: <T>(input: T & PreviouslyResolved & RetryInputConfig, defaults?: {
defaultMaxAttempts?: number;
defaultBaseDelay?: number;
}) => T & RetryResolvedConfig;
/**

@@ -59,0 +62,0 @@ * @internal

@@ -1,2 +0,2 @@

import type { Provider, RetryBackoffStrategy, RetryErrorInfo, RetryStrategyV2, StandardRetryToken } from "@smithy/types";
import type { Provider, RetryBackoffStrategy, RetryStrategyV2 } from "@smithy/types";
import { StandardRetryStrategy } from "./StandardRetryStrategy";

@@ -31,3 +31,2 @@ /**

constructor(maxAttempts: number | Provider<number>, computeNextBackoffDelay?: number | RetryBackoffStrategy["computeNextBackoffDelay"]);
refreshRetryTokenForRetry(tokenToRenew: StandardRetryToken, errorInfo: RetryErrorInfo): Promise<StandardRetryToken>;
}

@@ -10,2 +10,5 @@ import type { StandardRetryToken } from "@smithy/types";

private readonly longPoll;
$retryLog: {
acquisitionDelay: number;
};
constructor(delay: number, count: number, cost: number | undefined, longPoll: boolean);

@@ -12,0 +15,0 @@ getRetryCount(): number;

@@ -24,4 +24,4 @@ import type { Provider, RetryErrorInfo, RetryStrategyV2, StandardRetryBackoffStrategy, StandardRetryToken } from "@smithy/types";

readonly mode: string;
protected readonly retryBackoffStrategy: StandardRetryBackoffStrategy;
private capacity;
private readonly retryBackoffStrategy;
private readonly maxAttemptsProvider;

@@ -28,0 +28,0 @@ private readonly baseDelay;

{
"name": "@smithy/core",
"version": "3.24.5",
"version": "3.24.6",
"scripts": {

@@ -172,3 +172,3 @@ "build": "concurrently 'yarn:build:types' 'yarn:build:es:cjs'",

"@aws-crypto/crc32": "5.2.0",
"@smithy/types": "^4.14.2",
"@smithy/types": "^4.14.3",
"tslib": "^2.6.2"

@@ -175,0 +175,0 @@ },