fix: Implement fetch-retry locally #119
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What are the relevant tickets?
Relates to https://github.com/mitodl/hq/issues/7238
Description (What does it do?)
Ports a subset of fetch-retry into the project.
How can this be tested?
No functional change from the main branch.
Test criteria from feat: retry failed aichat requests #110 should pass.
Additional Context
#110 added fetch-retry as a dependency. Upgrading to the latest @mitodl/smoot-design in the MIT Learn project, the app runs without issue, though the Jest unit tests were seeing the error below:
The
tsc
build complies ESM and CommonJS builds from smoot-design source, excluding any dependencies, which are imported directly in projects. The fetch-retry produces a single UMD build with Rollup. The app works (uses the UMD version which gets bundled by the app's bundler), though running Jest the tests fail when (using the CJS smoot-design version and the UMD fetch-retry module directly). Jest module system doesn't seem to handle UMD modules as well as modern bundlers.Given the fetch-retry is small (full source), has no dependencies and we are only using a subset of it's API (we provide
retryDelay
andretryOn
as functions), it makes best sense to find alternatives to fetch-retry that would work better with dual-format packages or just port the code into the project. This PR does the latter.