Skip to content

Commit

Permalink
fix(transliterator): s3 uploads are not retried when slowed-down (#1438)
Browse files Browse the repository at this point in the history
In the observed logs, the slow down error return by S3 apparently do not
contain the human friendly names.
According to the S3 docs [1], a `503` error always indicates a slow down
request.
This PR adds a few more checks to detect retryable errors more reliably.

Also increases the wait time between retry requests slightly to make
slow downs less likely.

[1] https://repost.aws/knowledge-center/http-5xx-errors-s3

----

*By submitting this pull request, I confirm that my contribution is made
under the terms of the Apache-2.0 license*

---------

Signed-off-by: github-actions <[email protected]>
Co-authored-by: github-actions <[email protected]>
  • Loading branch information
mrgrain and github-actions authored Sep 9, 2024
1 parent bbb1625 commit a30b329
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/__tests__/__snapshots__/construct-hub.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/__tests__/devapp/__snapshots__/snapshot.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 8 additions & 2 deletions src/backend/transliterator/transliterator.ecstask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ interface S3Object {
*/
async function retry<A>(cb: () => Promise<A>): Promise<A> {
const deadline = Date.now() + 30_000; // Half a minute minute
let sleepMs = 10;
let sleepMs = 20;
while (true) {
try {
return await cb();
Expand All @@ -557,7 +557,13 @@ async function retry<A>(cb: () => Promise<A>): Promise<A> {

function isRetryableError(e: any) {
// Prepare for AWS SDK v3 already
return e.code === 'SlowDown' || e.name === 'SlowDown';
return (
e.code === 'SlowDown' ||
e.name === 'SlowDown' ||
e.code === 503 ||
e.statusCode === 503 ||
e.retryable === true
);
}

function sleep(ms: number): Promise<void> {
Expand Down

0 comments on commit a30b329

Please sign in to comment.