@@ -16,16 +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 > ) => <
27
+ export const retryMiddleware = ( options : RetryResolvedConfig ) => <
29
28
Output extends MetadataBearer = MetadataBearer
30
29
> (
31
30
next : FinalizeHandler < any , Output > ,
@@ -49,30 +48,19 @@ export const retryMiddleware = (options: RetryResolvedConfig & Partial<Previousl
49
48
request . headers [ INVOCATION_ID_HEADER ] = v4 ( ) ;
50
49
}
51
50
52
- let initialSystemClockOffset = 0 ;
53
-
54
51
while ( true ) {
55
52
try {
56
53
if ( isRequest ) {
57
54
request . headers [ REQUEST_HEADER ] = `attempt=${ attempts + 1 } ; max=${ maxAttempts } ` ;
58
55
}
59
- initialSystemClockOffset = options . systemClockOffset ?? 0 | 0 ;
60
56
const { response, output } = await next ( args ) ;
61
57
retryStrategy . recordSuccess ( retryToken ) ;
62
58
output . $metadata . attempts = attempts + 1 ;
63
59
output . $metadata . totalRetryDelay = totalRetryDelay ;
64
60
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 ) ;
61
+ } catch ( e : any ) {
62
+ const retryErrorInfo = getRetryErrorInfo ( e ) ;
63
+ lastError = asSdkError ( e ) ;
76
64
77
65
if ( isRequest && isStreamingPayload ( request ) ) {
78
66
( context . logger instanceof NoOpLogger ? console : context . logger ) ?. warn (
@@ -110,7 +98,7 @@ const isRetryStrategyV2 = (retryStrategy: RetryStrategy | RetryStrategyV2) =>
110
98
typeof ( retryStrategy as RetryStrategyV2 ) . refreshRetryTokenForRetry !== "undefined" &&
111
99
typeof ( retryStrategy as RetryStrategyV2 ) . recordSuccess !== "undefined" ;
112
100
113
- const getRetryErrorInfo = ( error : SkdErrorWithClockSkewMetadata ) : RetryErrorInfo => {
101
+ const getRetryErrorInfo = ( error : SdkError ) : RetryErrorInfo => {
114
102
const errorInfo : RetryErrorInfo = {
115
103
error,
116
104
errorType : getRetryErrorType ( error ) ,
@@ -122,7 +110,7 @@ const getRetryErrorInfo = (error: SkdErrorWithClockSkewMetadata): RetryErrorInfo
122
110
return errorInfo ;
123
111
} ;
124
112
125
- const getRetryErrorType = ( error : SkdErrorWithClockSkewMetadata ) : RetryErrorType => {
113
+ const getRetryErrorType = ( error : SdkError ) : RetryErrorType => {
126
114
if ( isThrottlingError ( error ) ) return "THROTTLING" ;
127
115
if ( isTransientError ( error ) ) return "TRANSIENT" ;
128
116
if ( isServerError ( error ) ) return "SERVER_ERROR" ;
0 commit comments