-
Notifications
You must be signed in to change notification settings - Fork 940
chore(site): reduce fetch interval on workspaces page #18725
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
… pending workspaces
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.
Pull Request Overview
This PR reduces the polling frequency on the Workspaces page by dynamically adjusting the refetch interval:
- Polls every 5s when any workspace build is in an intermediate state, otherwise every 30s.
- Disables polling on errors and when the tab is inactive.
Comments suppressed due to low confidence (2)
site/src/pages/WorkspacesPage/WorkspacesPage.tsx:80
- [nitpick] Consider adding unit or integration tests to verify that the polling interval switches correctly based on error states and active build presence.
refetchInterval: ({ state }) => {
site/src/pages/WorkspacesPage/WorkspacesPage.tsx:85
- workspace.latest_build may be undefined, causing runtime errors; use optional chaining (e.g.,
workspace.latest_build?.status
) or provide a default value to guard against missing builds.
const status = workspace.latest_build.status;
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.
seems legit
}, | ||
refetchOnWindowFocus: "always", |
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.
review: refetchInterval
does not execute while the tab is in the background, so the reduced refresh interval is more noticeable if you switch to a different tab and then switch back. Adding refetchOnWindowFocus
here seems like a good way to ensure that a user sees fresh data sooner. Alternatively, we could set refetchIntervalInBackground
but we then have to reason about two separate refresh loops. It also means that background Coder tabs will poll continuously, which does not seem desirable.
Relates to coder/internal#720
The workspaces query fetches a lot of information. We can probably reduce the frequency at which we fetch data by polling less often if no workspace builds are in 'intermediate' states.