Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions packages/middleware-retry/src/retryDecider.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { RETRYABLE_STATUS_CODES } from "./constants";
import {
isClockSkewError,
isStillProcessingError,
isThrottlingError
} from "@aws-sdk/service-error-classification";
import { MetadataBearer, SdkError } from "@aws-sdk/types";
Expand All @@ -23,11 +22,7 @@ export const defaultRetryDecider = (error: SdkError) => {
return true;
}

return (
isStillProcessingError(error) ||
isThrottlingError(error) ||
isClockSkewError(error)
);
return isThrottlingError(error) || isClockSkewError(error);
};

function hasMetadata(error: any): error is MetadataBearer {
Expand Down
21 changes: 10 additions & 11 deletions packages/service-error-classification/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,24 @@ export const CLOCK_SKEW_ERROR_CODES = [
"SignatureDoesNotMatch"
];

/**
* Errors encountered when the state presumed by an operation is not yet ready.
*/
export const STILL_PROCESSING_ERROR_CODES = ["PriorRequestNotComplete"];

/**
* Errors that indicate the SDK is being throttled.
*
* These errors are always retryable.
*/
export const THROTTLING_ERROR_CODES = [
"BandwidthLimitExceeded",
"Throttling",
"ThrottlingException",
"ThrottledException",
"RequestThrottledException",
"TooManyRequestsException",
"ProvisionedThroughputExceededException",
"TransactionInProgressException",
"RequestLimitExceeded",
"BandwidthLimitExceeded",
"LimitExceededException",
"RequestThrottled",
"RequestThrottledException",
"SlowDown",
"ThrottledException",
"Throttling",
"ThrottlingException",
"TooManyRequestsException"
"PriorRequestNotComplete",
"EC2ThrottledException"
];
30 changes: 2 additions & 28 deletions packages/service-error-classification/src/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
import {
CLOCK_SKEW_ERROR_CODES,
STILL_PROCESSING_ERROR_CODES,
THROTTLING_ERROR_CODES
} from "./constants";
import {
isClockSkewError,
isStillProcessingError,
isThrottlingError
} from "./index";
import { CLOCK_SKEW_ERROR_CODES, THROTTLING_ERROR_CODES } from "./constants";
import { isClockSkewError, isThrottlingError } from "./index";

const checkForErrorType = (
isErrorTypeFunc: (error: Error) => boolean,
Expand Down Expand Up @@ -37,24 +29,6 @@ describe("isClockSkewError", () => {
}
});

describe("isStillProcessingError", () => {
STILL_PROCESSING_ERROR_CODES.forEach(name => {
it(`should declare error with the name "${name}" to be a StillProcessing error`, () => {
checkForErrorType(isStillProcessingError, name, true);
});
});

while (true) {
const name = Math.random().toString(36).substring(2);
if (!STILL_PROCESSING_ERROR_CODES.includes(name)) {
it(`should not declare error with the name "${name}" to be a StillProcessing error`, () => {
checkForErrorType(isStillProcessingError, name, false);
});
break;
}
}
});

describe("isThrottlingError", () => {
THROTTLING_ERROR_CODES.forEach(name => {
it(`should declare error with the name "${name}" to be a Throttling error`, () => {
Expand Down
9 changes: 1 addition & 8 deletions packages/service-error-classification/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,7 @@
import {
CLOCK_SKEW_ERROR_CODES,
STILL_PROCESSING_ERROR_CODES,
THROTTLING_ERROR_CODES
} from "./constants";
import { CLOCK_SKEW_ERROR_CODES, THROTTLING_ERROR_CODES } from "./constants";

export const isClockSkewError = (error: Error) =>
CLOCK_SKEW_ERROR_CODES.includes(error.name);

export const isStillProcessingError = (error: Error) =>
STILL_PROCESSING_ERROR_CODES.includes(error.name);

export const isThrottlingError = (error: Error) =>
THROTTLING_ERROR_CODES.includes(error.name);