Feature/add timeout to client requests #141
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.
This feature adds timeout functionality to the client and server-sides of our chat application. On the client side we timeout the request after a specified duration (default 120s). Once the timeout occurs, the client will display the "Oops!" error message.
We also need to handle request timeouts at the server. Simply timing out a request from the client does not stop the server from trying to process the request (and calling OpenAI), only to produce a result that will be in vain. Thus, right before we call the Chain, we check to see if the timeout has already occurred. If so, we return an error instead of executing the request.
I also made some minor changes to the front-end:
try-catch
block around ourfetch
calls forlikeResponse
anddislikeResponse
, as these methods will currently fail if/when a user likes/dislikes an "Oops!" message.