@@ -16,18 +16,15 @@ import {
16
16
RetryStrategyV2 ,
17
17
RetryToken ,
18
18
SdkError ,
19
- SkdErrorWithClockSkewMetadata ,
20
19
} from "@smithy/types" ;
21
20
import { INVOCATION_ID_HEADER , REQUEST_HEADER } from "@smithy/util-retry" ;
22
21
import { v4 } from "uuid" ;
23
22
24
- import { PreviouslyResolved , RetryResolvedConfig } from "./configurations" ;
23
+ import { RetryResolvedConfig } from "./configurations" ;
25
24
import { isStreamingPayload } from "./isStreamingPayload/isStreamingPayload" ;
26
25
import { asSdkError } from "./util" ;
27
26
28
- export const retryMiddleware = ( options : RetryResolvedConfig & Partial < PreviouslyResolved > ) => <
29
- Output extends MetadataBearer = MetadataBearer
30
- > (
27
+ export const retryMiddleware = ( options : RetryResolvedConfig ) => < Output extends MetadataBearer = MetadataBearer > (
31
28
next : FinalizeHandler < any , Output > ,
32
29
context : HandlerExecutionContext
33
30
) : FinalizeHandler < any , Output > => async (
@@ -49,30 +46,19 @@ export const retryMiddleware = (options: RetryResolvedConfig & Partial<Previousl
49
46
request . headers [ INVOCATION_ID_HEADER ] = v4 ( ) ;
50
47
}
51
48
52
- let initialSystemClockOffset = 0 ;
53
-
54
49
while ( true ) {
55
50
try {
56
51
if ( isRequest ) {
57
52
request . headers [ REQUEST_HEADER ] = `attempt=${ attempts + 1 } ; max=${ maxAttempts } ` ;
58
53
}
59
- initialSystemClockOffset = options . systemClockOffset ?? 0 | 0 ;
60
54
const { response, output } = await next ( args ) ;
61
55
retryStrategy . recordSuccess ( retryToken ) ;
62
56
output . $metadata . attempts = attempts + 1 ;
63
57
output . $metadata . totalRetryDelay = totalRetryDelay ;
64
58
return { response, output } ;
65
- } catch ( e : unknown ) {
66
- const latestSystemClockOffset = options . systemClockOffset ?? 0 | 0 ;
67
- const clockSkewCorrected = initialSystemClockOffset !== latestSystemClockOffset ;
68
-
69
- const sdkError = e as SkdErrorWithClockSkewMetadata ;
70
- if ( clockSkewCorrected && sdkError . $metadata && typeof sdkError . $metadata === "object" ) {
71
- sdkError . $metadata . clockSkewCorrected = true ;
72
- }
73
-
74
- const retryErrorInfo = getRetryErrorInfo ( sdkError ) ;
75
- lastError = asSdkError ( sdkError ) ;
59
+ } catch ( e : any ) {
60
+ const retryErrorInfo = getRetryErrorInfo ( e ) ;
61
+ lastError = asSdkError ( e ) ;
76
62
77
63
if ( isRequest && isStreamingPayload ( request ) ) {
78
64
( context . logger instanceof NoOpLogger ? console : context . logger ) ?. warn (
@@ -110,7 +96,7 @@ const isRetryStrategyV2 = (retryStrategy: RetryStrategy | RetryStrategyV2) =>
110
96
typeof ( retryStrategy as RetryStrategyV2 ) . refreshRetryTokenForRetry !== "undefined" &&
111
97
typeof ( retryStrategy as RetryStrategyV2 ) . recordSuccess !== "undefined" ;
112
98
113
- const getRetryErrorInfo = ( error : SkdErrorWithClockSkewMetadata ) : RetryErrorInfo => {
99
+ const getRetryErrorInfo = ( error : SdkError ) : RetryErrorInfo => {
114
100
const errorInfo : RetryErrorInfo = {
115
101
error,
116
102
errorType : getRetryErrorType ( error ) ,
@@ -122,7 +108,7 @@ const getRetryErrorInfo = (error: SkdErrorWithClockSkewMetadata): RetryErrorInfo
122
108
return errorInfo ;
123
109
} ;
124
110
125
- const getRetryErrorType = ( error : SkdErrorWithClockSkewMetadata ) : RetryErrorType => {
111
+ const getRetryErrorType = ( error : SdkError ) : RetryErrorType => {
126
112
if ( isThrottlingError ( error ) ) return "THROTTLING" ;
127
113
if ( isTransientError ( error ) ) return "TRANSIENT" ;
128
114
if ( isServerError ( error ) ) return "SERVER_ERROR" ;
0 commit comments