Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(node-http-handler): check for error code in isTransientError #4018

Merged
merged 1 commit into from Oct 5, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/node-http-handler/src/constants.ts
@@ -1,4 +1,5 @@
/**
* Node.js system error codes that indicate timeout.
* @deprecated use NODEJS_TIMEOUT_ERROR_CODES from @aws-sdk/service-error-classification/constants
*/
export const NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
5 changes: 5 additions & 0 deletions packages/service-error-classification/src/constants.ts
Expand Up @@ -45,3 +45,8 @@ export const TRANSIENT_ERROR_CODES = ["AbortError", "TimeoutError", "RequestTime
* Error codes that indicate transient issues
*/
export const TRANSIENT_ERROR_STATUS_CODES = [500, 502, 503, 504];

/**
* Node.js system error codes that indicate timeout.
*/
export const NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];
8 changes: 8 additions & 0 deletions packages/service-error-classification/src/index.ts
Expand Up @@ -2,6 +2,7 @@ import { SdkError } from "@aws-sdk/types";

import {
CLOCK_SKEW_ERROR_CODES,
NODEJS_TIMEOUT_ERROR_CODES,
THROTTLING_ERROR_CODES,
TRANSIENT_ERROR_CODES,
TRANSIENT_ERROR_STATUS_CODES,
Expand All @@ -16,6 +17,13 @@ export const isThrottlingError = (error: SdkError) =>
THROTTLING_ERROR_CODES.includes(error.name) ||
error.$retryable?.throttling == true;

/**
* Though NODEJS_TIMEOUT_ERROR_CODES are platform specific, they are
* included here because there is an error scenario with unknown root
* cause where the NodeHttpHandler does not decorate the Error with
* the name "TimeoutError" to be checked by the TRANSIENT_ERROR_CODES condition.
*/
export const isTransientError = (error: SdkError) =>
TRANSIENT_ERROR_CODES.includes(error.name) ||
NODEJS_TIMEOUT_ERROR_CODES.includes((error as { code?: string })?.code || "") ||
TRANSIENT_ERROR_STATUS_CODES.includes(error.$metadata?.httpStatusCode || 0);