Skip to content

Commit

Permalink
If request has a streamed body then don't retry
Browse files Browse the repository at this point in the history
Retying a streamed request might mean the initial part of the stream is missing.
  • Loading branch information
adam-fowler committed Nov 18, 2024
1 parent 9d44bcd commit 50dd0a4
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions Sources/SotoCore/Middleware/Middleware/RetryMiddleware.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ struct RetryMiddleware: AWSMiddlewareProtocol {
try Task.checkCancellation()
return try await next(request, context)
} catch {
// If request is streaming then do not allow a retry
if request.body.isStreaming {
throw error
}
// If I get a retry wait time for this error then attempt to retry request
if case .retry(let retryTime) = self.retryPolicy.getRetryWaitTime(error: error, attempt: attempt) {
context.logger.trace("Retrying request", metadata: [
Expand Down

0 comments on commit 50dd0a4

Please sign in to comment.