-
Notifications
You must be signed in to change notification settings - Fork 0
feat: retry failed aichat requests #110
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
e79be88
to
70e0731
Compare
/** | ||
* If true, the chat input will be autofocused on load. | ||
* Defaults to true. | ||
*/ | ||
autofocus?: boolean |
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.
This slipped in from our other issue.
return false | ||
} | ||
if (response) { | ||
if (response.status < 400) return false |
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.
Is this just for good measure? I wouldn't expect any status < 400 to produce an error to retry on.
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.
This is actually necessary: If you implement retryOn
as a function, then that is what determines retry, period.
And for fetch:
- promise resolve = network response (possibly an error response, based on status code)
- promise reject = network error
So we really do need to check the status code and explicitly say "Do not retry if < 400".
Alternatively, we could specify retryOn: <array of whitelisted status codes to retry>
.
But if we want to retry everything except a specific list, then we need to do it this way.
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.
Looks great, works great!
🎉 This PR is included in version 6.5.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
What are the relevant tickets?
Closes https://github.com/mitodl/hq/issues/7238
Description (What does it do?)
This PR enables retries on failed AiChat requests. Requests are retried 3 times with exponential backoff, 1s, 2s, 4s.
Screenshots (if appropriate):
How can this be tested?
The easiest way to test this is illustrated in the screenshot above:
yarn start
and navigate to http://localhost:6006/?path=/docs/smoot-design-ai-aichat--docs