-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature/server health check #349
Conversation
…undant check" This reverts commit f3ae249.
…, so allow them to set the callback function
…utton when response comes in
jest coverage report 🧪Total coverage
Show files with reduced coverage 🔻Reduced coverage
|
075236e
to
3002aed
Compare
This reverts commit e253436.
@@ -313,7 +316,7 @@ export class WebsocketClient { | |||
jsonData: Record<string, unknown>, | |||
requestDescription: string | |||
): void { | |||
if (this.socketIsValid()) { | |||
if (this.socketIsConnected()) { |
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.
I ran into this issue when testing where the socket can be "valid" (which means the websocket's state isn't CLOSED), but not "connected" (which means the websocket's state is OPEN) if the state is PENDING, in which case sending a message throws an error. I feel like this check is trying to prevent that error, so might as well cover the PENDING case too?
Can confirm I just got this working in a preliminary way in the website! More work to clean up the front end before PR but the viewer side is doing what it should do. LGTM, thanks @ascibisz ! |
src/controller/index.ts
Outdated
netConnectionConfig: NetConnectionParams | ||
): void { | ||
if ( | ||
!this.simulator || | ||
!(this.simulator instanceof RemoteSimulator) || | ||
!this.simulator.socketIsValid() | ||
) { | ||
// Only configure network if we aren't already connected to the remote server | ||
this.configureNetwork(netConnectionConfig); |
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.
It feels a bit funny to have to pass the config in every time we make a check, it looks redundant on the front-end, but it does ensure we aren't querying an un-configured controller that won't respond.
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.
Yeah it does sort of make sense that you might want to check health before a connection was made.
} | ||
if (this.simulator && this.simulator instanceof RemoteSimulator) { | ||
this.simulator.setHealthCheckHandler(handler); | ||
this.simulator.checkServerHealth(); |
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.
should checkServerHealth accept a callback as an arg instead of having a separate setter? Are they always called together like this?
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.
I see why they are separate now, because of the message passing and receiving.
@@ -47,6 +47,9 @@ export const enum NetMessageEnum { | |||
ID_AVAILABLE_METRICS_RESPONSE = 18, | |||
ID_PLOT_DATA_REQUEST = 19, | |||
ID_PLOT_DATA_RESPONSE = 20, | |||
ID_ERROR_MSG = 21, | |||
ID_CHECK_HEALTH_REQUEST = 22, | |||
ID_SERVER_HEALTHY_RESPONSE = 23, |
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 there any documentation in this repo for what these messages are supposed to mean, or their payload schema? (One thing that is nice to know is whether it's intended to go from client to server or vice versa)
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 isn't... I do have it fairly well documentation in the Octopus repo though, so I should probably copy that over
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.
I realize it's not great that it would have to be kept up in two places but it's also true that if it changes in octopus, then something would have to change over here too.
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.
Yeah and that's true of the message types themselves. We're already in a slightly weird situation, may as well have it be a better documented weird situation!
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.
I left a bunch of comments but basically this seems ok. I would love to clean up the connection logic but probably out of scope for this.
src/simularium/RemoteSimulator.ts
Outdated
.catch((e) => { | ||
throw new FrontEndError(e.message, ErrorLevel.ERROR); | ||
}); |
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.
Questions about error handling.
UX request is that if "server is down" we throw a styled modal.
But if the viewer can't connect this error also generates up a full screen React runtime error.
Removing this error handling yields the behavior UX asked for (just a modal), but is that not proper error handling?
Problem
The server health check has existed in Octopus for a while now, time to take it in to the viewer!
One part of this ticket. The other piece of that ticket will include adding a health check call, similar to the one implemented here in the example viewer, to the simualrium-website in the early stages of the autoconversion form.
Also added in support for handling error messages octopus sends now, which is another new message type that has existed in Octopus for a bit.
Solution
Paired on this with with @interim17
Type of change
Change summary:
ID_ERROR_MSG = 21
andID_SERVER_HEALTHY_RESPONSE = 23
ID_CHECK_HEALTH_REQUEST = 22
, which octopus already knows how to handle