Skip to content

Commit 7c7c28b

Browse files
sichanyooSichan Yoo
andauthored
fix: Include 3 transient CRT HTTP client errors to retried errors (#972)
* Add retry for CRT HTTP client's socket closed error. * Add 1048 transient error also. * Add 1067 CRT error code as retryable. --------- Co-authored-by: Sichan Yoo <[email protected]>
1 parent fa734d4 commit 7c7c28b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Sources/ClientRuntime/Retries/DefaultRetryErrorInfoProvider.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import protocol SmithyRetriesAPI.RetryErrorInfoProvider
1212
import struct Foundation.TimeInterval
1313
import class Foundation.NSError
1414
import var Foundation.NSURLErrorDomain
15+
import struct AwsCommonRuntimeKit.CRTError
16+
import enum AwsCommonRuntimeKit.CommonRunTimeError
1517

1618
public enum DefaultRetryErrorInfoProvider: RetryErrorInfoProvider, Sendable {
1719
/// Returns information used to determine how & if to retry an error.
@@ -41,6 +43,21 @@ public enum DefaultRetryErrorInfoProvider: RetryErrorInfoProvider, Sendable {
4143
// NSURLErrorTimedOut = -1001
4244
// "The request timed out."
4345
return .init(errorType: .transient, retryAfterHint: nil, isTimeout: true)
46+
} else if let crtError = error as? CommonRunTimeError,
47+
case .crtError(let crtErrorStruct) = crtError,
48+
crtErrorStruct.code == 1051 {
49+
// Retries CRTError(code: 1051, message: "socket is closed.", name: "AWS_IO_SOCKET_CLOSED"))
50+
return .init(errorType: .transient, retryAfterHint: nil, isTimeout: false)
51+
} else if let crtError = error as? CommonRunTimeError,
52+
case .crtError(let crtErrorStruct) = crtError,
53+
crtErrorStruct.code == 1048 {
54+
// Retries CRTError(code: 1048, message: "socket operation timed out.", name: "AWS_IO_SOCKET_TIMEOUT"))
55+
return .init(errorType: .transient, retryAfterHint: nil, isTimeout: true)
56+
} else if let crtError = error as? CommonRunTimeError,
57+
case .crtError(let crtErrorStruct) = crtError,
58+
crtErrorStruct.code == 1067 {
59+
// Retries CRTError(code: 1067, message: "Channel shutdown due to tls negotiation timeout", name: "AWS_IO_TLS_NEGOTIATION_TIMEOUT"))
60+
return .init(errorType: .transient, retryAfterHint: nil, isTimeout: true)
4461
}
4562
return nil
4663
}

0 commit comments

Comments
 (0)