-
Notifications
You must be signed in to change notification settings - Fork 1
[DEV-2397] Refactor S3 metadata helpers to include retry logic for fetching file… #1516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…s and metadata. Added exponential backoff for retries and improved error logging. Updated subproject commit to indicate a dirty state.
- Implemented retry logic with exponential backoff for `downloadFileAsText()` and `fetchMetadataFromCDN()` - Introduced environment variables `CDN_RETRY_ATTEMPTS` and `CDN_RETRY_DELAY_MS` for customization - Enhanced error handling and logging for CDN fetch failures - Resolved 404 errors on guide pages when CloudFront cache is not warmed up
🦋 Changeset detectedLatest commit: 70a2d25 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
if (attempt < RETRY_ATTEMPTS) { | ||
const delayMs = INITIAL_RETRY_DELAY_MS * Math.pow(2, attempt - 1); // Exponential backoff | ||
console.log(`Retrying in ${delayMs}ms...`); | ||
await delay(delayMs); | ||
} | ||
} | ||
} | ||
|
||
console.error( | ||
`Failed to download file after ${RETRY_ATTEMPTS} attempts:`, | ||
lastError | ||
); | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isntead of duplicate code for retry maybe we can have a shared function that handle retries used in both downloadFileAsText and fetchMetadataFromCDN
- Introduced a `withRetries` function to handle retry logic for asynchronous operations, enhancing code reusability. - Updated `downloadFileAsText` and `fetchMetadataFromCDN` to leverage the new retry function, improving error handling and logging. - Maintained existing functionality while streamlining the retry process for better maintainability.
Jira Pull Request LinkThis Pull Request refers to the following Jira issue DEV-2397 |
Branch is not up to date with base branch@tommaso1 it seems this Pull Request is not updated with base branch. |
…s and metadata. Added exponential backoff for retries and improved error logging. Updated subproject commit to indicate a dirty state.
List of Changes
downloadFileAsText()
andfetchMetadataFromCDN()
functionsCDN_RETRY_ATTEMPTS
(default: 3) andCDN_RETRY_DELAY_MS
(default: 5000ms)Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: