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

chore: Remove retry-after header support #1814

Merged
merged 2 commits into from
Nov 8, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,6 @@ public enum AWSRetryErrorInfoProvider: RetryErrorInfoProvider {

public static func errorInfo(for error: Error) -> RetryErrorInfo? {

// Look for a header with a retry after value; use it as retry after hint
var retryAfterHint: TimeInterval?
if let headers = (error as? HTTPError)?.httpResponse.headers,
let delayString = headers.value(for: "Retry-After") ?? headers.value(for: "X-Amz-Retry-After"),
let delay = TimeInterval(delayString) {
retryAfterHint = delay
}

// Determine based on properties if this error is a timeout error.
var isTimeout = false

Expand All @@ -75,32 +67,32 @@ public enum AWSRetryErrorInfoProvider: RetryErrorInfoProvider {
// Handle certain CRT errors as transient errors
if case CommonRunTimeError.crtError(let crtError) = error {
if transientCRTErrorCodes.contains(crtError.code) {
return RetryErrorInfo(errorType: .transient, retryAfterHint: retryAfterHint, isTimeout: isTimeout)
return RetryErrorInfo(errorType: .transient, retryAfterHint: nil, isTimeout: isTimeout)
}
}

if let serviceError = error as? ServiceError, let code = serviceError.typeName {
// Handle the throttling error codes as errors of retry type "throttling".
if throttlingErrorCodes.contains(code) {
return RetryErrorInfo(errorType: .throttling, retryAfterHint: retryAfterHint, isTimeout: false)
return RetryErrorInfo(errorType: .throttling, retryAfterHint: nil, isTimeout: false)
}
// Handle the transient error codes as errors of retry type "transient".
if transientErrorCodes.contains(code) {
return RetryErrorInfo(errorType: .transient, retryAfterHint: retryAfterHint, isTimeout: isTimeout)
return RetryErrorInfo(errorType: .transient, retryAfterHint: nil, isTimeout: isTimeout)
}
}

if let httpError = error as? HTTPError {
// Handle the transient and timeout HTTP status codes as errors of retry type "transient".
if (transientStatusCodes + timeoutStatusCodes).contains(httpError.httpResponse.statusCode.rawValue) {
return RetryErrorInfo(errorType: .transient, retryAfterHint: retryAfterHint, isTimeout: isTimeout)
return RetryErrorInfo(errorType: .transient, retryAfterHint: nil, isTimeout: isTimeout)
}
}

if let modeledError = error as? ModeledError, type(of: modeledError).typeName == "IDPCommunicationError" {

// Handle a modeled IDPCommunicationError (comes from STS) as an error of retry type "transient".
return RetryErrorInfo(errorType: .transient, retryAfterHint: retryAfterHint, isTimeout: isTimeout)
return RetryErrorInfo(errorType: .transient, retryAfterHint: nil, isTimeout: isTimeout)
}

// If custom AWS error matching fails, use the default error info provider to finish matching.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,20 +80,6 @@ class AWSRetryErrorInfoProviderTests: XCTestCase {
}
}

// MARK: - Retry after hint

func test_retryAfterHint_setsRetryAfterHintWhenRetryAfterHeaderIsSetWithSeconds() throws {
let error = try TestHTTPError(statusCode: 500, headers: ["retry-after": "2.8"])
let errorInfo = AWSRetryErrorInfoProvider.errorInfo(for: error)
XCTAssertEqual(errorInfo?.retryAfterHint, 2.8)
}

func test_retryAfterHint_setsRetryAfterHintWhenXAmzRetryAfterHeaderIsSetWithSeconds() throws {
let error = try TestHTTPError(statusCode: 500, headers: ["x-amz-retry-after": "2.7"])
let errorInfo = AWSRetryErrorInfoProvider.errorInfo(for: error)
XCTAssertEqual(errorInfo?.retryAfterHint, 2.7)
}

// MARK: - isTimeout

func test_isTimeout_setsIsTimeoutWhenHTTPStatusCodeIndicatesTimeout() throws {
Expand Down
Loading