File tree Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Expand file tree Collapse file tree 1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,16 @@ import { Credentials, fromStaticCredentials } from "./credentials.ts";
66import type { AwsErrorMeta } from "./error.ts" ;
77import { DefaultFetch , Fetch } from "./fetch.service.ts" ;
88import type { ProtocolHandler } from "./protocols/interface.ts" ;
9+ import * as Schedule from "effect/Schedule" ;
10+
11+ export const retryableErrorTags = [
12+ "InternalFailure" ,
13+ "RequestExpired" ,
14+ "ServiceException" ,
15+ "ServiceUnavailable" ,
16+ "ThrottlingException" ,
17+ "TooManyRequestsException" ,
18+ ] ;
919
1020const errorTags : {
1121 [ serviceName : string ] : {
@@ -247,7 +257,21 @@ export function createServiceProxy<T>(
247257 ) ;
248258 }
249259 } ) ;
250- return program ;
260+
261+ return program . pipe (
262+ Effect . tapError ( ( e ) =>
263+ Effect . logDebug ( "AWS Request Failed, Retrying..." , {
264+ error : e ,
265+ } ) ,
266+ ) ,
267+ Effect . retry ( {
268+ schedule : Schedule . intersect (
269+ Schedule . exponential ( "100 millis" ) ,
270+ Schedule . recurs ( 5 ) ,
271+ ) ,
272+ while : ( e ) => retryableErrorTags . includes ( e . _tag ) ,
273+ } ) ,
274+ ) ;
251275 } ;
252276 } ,
253277 } ,
You can’t perform that action at this time.
0 commit comments