-
Notifications
You must be signed in to change notification settings - Fork 12
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
622 backend health endpoint #639
Conversation
17b0454
to
74e9ed3
Compare
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.
All looks good! Not too worried about the concerns. Re the double message, would it be good enough to, in addErrorMessage()
quickly check if the last message
is identical to the one you're about to add?
That didn't quite work as when the second render checked the messages array, it was still empty o.O but I think I found a way around this using |
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.
beautiful!
In the future it might be good to disable stuff (like sending messages) if the backend is down, but that's a different ticket
Yeah agreed. As you say, best to make a new ticket as there might be other things that would be worth disabling if the backend is offline. I'll make a new ticket now... #640 Also, I changed how to show the error message yet again :') Now I'm just setting the whole messages array to be the error message if the backend isn't up. Should be fine as we're checking this when the frontend starts and there's no backend. So there won't be any existing chat history (can't retrieve it from the backend). This avoids using |
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.
that works too!
Another case is when the server goes down while the user is on the system. Edge case, but might be worth thinking about. Also something for another ticket.
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.
Very nice! just the one comment from me
// perform backend health check | ||
healthCheck().catch(() => { | ||
// addErrorMessage('Failed to reach the server. Please try again later.'); | ||
setMessages([ |
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.
could we do
setMessages((messages) => [
...messages,
{
message: 'Failed to reach the server. Please try again later.',
type: CHAT_MESSAGE_TYPE.ERROR_MSG,
},
]);
to stop any user input disappearing?
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.
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.
hm i was able to send messages before seeing the message, so my message would disappear. I see it's niche so happy to approve
* Backend health check endpoint * Showing error if the backend isn't running * Only showing the error once * No longer using useRef to show one error message
Description
Added a health check endpoint on the backend, and now showing an error on the frontend if the backend isn't running.
Screenshots
Concerns
The error shows twice because of React rendering things twice in debug mode.- no longer, now just setting the whole chat history to be the error message, rather than adding the error message.Checklist
Have you done the following?