Skip to content

Commit ab0e7be

Browse files
authoredOct 5, 2022
fix(node-http-handler): check for error code in isTransientError (#4018)
1 parent 6ff07bd commit ab0e7be

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/**
22
* Node.js system error codes that indicate timeout.
3+
* @deprecated use NODEJS_TIMEOUT_ERROR_CODES from @aws-sdk/service-error-classification/constants
34
*/
45
export const NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];

‎packages/service-error-classification/src/constants.ts

+5
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,8 @@ export const TRANSIENT_ERROR_CODES = ["AbortError", "TimeoutError", "RequestTime
4545
* Error codes that indicate transient issues
4646
*/
4747
export const TRANSIENT_ERROR_STATUS_CODES = [500, 502, 503, 504];
48+
49+
/**
50+
* Node.js system error codes that indicate timeout.
51+
*/
52+
export const NODEJS_TIMEOUT_ERROR_CODES = ["ECONNRESET", "EPIPE", "ETIMEDOUT"];

‎packages/service-error-classification/src/index.ts

+8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { SdkError } from "@aws-sdk/types";
22

33
import {
44
CLOCK_SKEW_ERROR_CODES,
5+
NODEJS_TIMEOUT_ERROR_CODES,
56
THROTTLING_ERROR_CODES,
67
TRANSIENT_ERROR_CODES,
78
TRANSIENT_ERROR_STATUS_CODES,
@@ -16,6 +17,13 @@ export const isThrottlingError = (error: SdkError) =>
1617
THROTTLING_ERROR_CODES.includes(error.name) ||
1718
error.$retryable?.throttling == true;
1819

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

0 commit comments

Comments
 (0)
Please sign in to comment.