- Notifications
You must be signed in to change notification settings - Fork1k
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
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;
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
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
?ACTIVE_BUILDS_REFRESH_INTERVAL | ||
:NO_ACTIVE_BUILDS_REFRESH_INTERVAL; | ||
}, | ||
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. AddingrefetchOnWindowFocus
here seems like a good way to ensure that a user sees fresh data sooner. Alternatively, we could setrefetchIntervalInBackground
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.
1195f31
intomainUh oh!
There was an error while loading.Please reload this page.
Relates tocoder/internal#720
The workspaces query fetches alot 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.