Skip to content
Open
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
26 changes: 25 additions & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ import { Credentials, fromStaticCredentials } from "./credentials.ts";
import type { AwsErrorMeta } from "./error.ts";
import { DefaultFetch, Fetch } from "./fetch.service.ts";
import type { ProtocolHandler } from "./protocols/interface.ts";
import * as Schedule from "effect/Schedule";

export const retryableErrorTags = [
"InternalFailure",
"RequestExpired",
"ServiceException",
"ServiceUnavailable",
"ThrottlingException",
"TooManyRequestsException",
];
Comment on lines +11 to +18
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this all of the errors? Can we extract them. Maybe the smithy models has information we cam use, e.g. all 5xx errors should be retried. Maybe there's other metadata.


const errorTags: {
[serviceName: string]: {
Expand Down Expand Up @@ -247,7 +257,21 @@ export function createServiceProxy<T>(
);
}
});
return program;

return program.pipe(
Effect.tapError((e) =>
Effect.logDebug("AWS Request Failed, Retrying...", {
error: e,
}),
),
Effect.retry({
schedule: Schedule.intersect(
Schedule.exponential("100 millis"),
Schedule.recurs(5),
),
while: (e) => retryableErrorTags.includes(e._tag),
}),
);
Comment on lines +261 to +274
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a way we can make this configurable or injectable as a layer with a sensible default.

};
},
},
Expand Down
Loading