-
Notifications
You must be signed in to change notification settings - Fork 936
feat: use sse for workspace page #4122
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
If SSE fails and we're in the |
How should we handle SSE errors? Should the page show something about failing to refresh data? Maybe a warning-style thing rather than error-style, like when your workspace is going to stop soon? |
The backend will close the connection when we get a non-recoverable error. My first thought is to console log the errors we get or something low-stakes like that, and just keep it open unless the backend closes it. A non-fatal error may be a momentary db issue, but the next message may come through fine. On the connection being closed we should retry, probably with a backoff. |
@presleyp good catch; this should be fixed.
@presleyp Right now, SSE errors will not block the user from viewing the page. I will put up a subsequent PR with a new, warning style message indicating workspace data might not be up to date if that field is populated. I want to handle that separately because there are several workspace error cleanup items to tackle and it would be nice to have them all in 1 PR.
@f0ssel Yeah, we should add a backoff. Right now, we close, wait a second and then try again with a new connection. I would like to add that backoff when I add the warning described above. |
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.
Sorry, I could've sworn I got this review in last night!
resolves #4058
Based on @f0ssel's implementation of SSE on the BE, we are now using SSE on the FE to get workspace and resource updates (instead of polling).
Background
Previously, we fetched a workspace, template, and permissions, and then we started two separate polling states: we polled for workspace, and we polled for resources.
Since @f0ssel's implementation returns both workspace and resources in one object, we are able to simplify.
Now: we fetch a workspace, template, and permissions, and then we initialize an
EventSource
that returns workspace and workspace-related data as the server updates the client.To Test
Pull down the branch and open a workspace; make sure the workspace and resources load.

Open Chrome inspect and check out the network tab: you should be able to see a watch request that shows events streaming in: