Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove extraneous polling #382

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

Merged
merged 10 commits into from
Oct 14, 2024
Merged

Remove extraneous polling #382

merged 10 commits into from
Oct 14, 2024

Conversation

code-asher
Copy link
Member

@code-asher code-asher commented Oct 14, 2024

Previously, we were polling all the user's workspaces to get information
about autostop and deletion so we can notify the user when those things
are about to happen.

This has a few problems:

  1. We really only want to notify for the workspace to which we are
    actively connected, not all workspaces.
  2. It did not account for owners being connected to someone else's
    workspace. We would have to query all workspaces, which is an even
    more expensive query.
  3. If the sidebar is open, we are running two of the same query every
    five seconds, which is wasteful.

We already had a web socket that was used to notify about the workspace
being outdated, so I broke that into a new class and combined all the
notifications (outdated, autostop, deletion), status bar updates (just
shows if the workspace is outdated), and context updates into one place
using that web socket.

Secondly, fix an issue where we immediately start polling when connecting
to a remote even though the Coder sidebar is not visible.

Now, we should only be polling when the sidebar is visible.

This should never be called directly.
@code-asher code-asher self-assigned this Oct 14, 2024
@code-asher code-asher changed the title Use web socket for workspace notifications Reduce extraneous polling Oct 14, 2024
@code-asher code-asher changed the title Reduce extraneous polling Remove extraneous polling Oct 14, 2024
@code-asher code-asher force-pushed the asher/reduce-polling branch from 72ac15d to 5609d21 Compare October 14, 2024 21:14
@code-asher code-asher force-pushed the asher/reduce-polling branch 2 times, most recently from 18352d7 to 59f704d Compare October 14, 2024 21:38
Previously, we were polling all the user's workspaces to get information
about autostop and deletion so we can notify the user when those things
are about to happen.

This has a few problems:

1. We really only want to notify for the workspace to which we are
   actively connected, not all workspaces.
2. It did not account for owners being connected to someone else's
   workspace.  We would have to query all workspaces, which is an even
   more expensive query.
3. If the sidebar is open, we are running two of the same query every
   five seconds, which is wasteful.

We already had a web socket that was used to notify about the workspace
being outdated, so I broke that into a new class and combined all the
notification (outdated, autostop, deletion), status bar updates (just
shows if the workspace is outdated), and context updates into one place
using that web socket.
Now, calling fetchAndRefresh() is a no-op if the view is not visible.
It says the window will reload, but the command has no way of knowing
that is the case.  Maybe the command could automatically reload, but for
now, a second notification will inform the user that the window needs to
be reloaded, and they can choose whether they want to do so.
@code-asher code-asher removed the request for review from bcpeinhardt October 14, 2024 22:13
After experimentation, I think this is better.  The idea with the
notification was that it would not be in the way, but I think this is
really something you need to be aware of and ideally you should
immediately reload.

Also, only show it once.
@code-asher code-asher force-pushed the asher/reduce-polling branch from 59f704d to 9e578dd Compare October 14, 2024 22:19
@code-asher code-asher merged commit 39bbc89 into main Oct 14, 2024
2 checks passed
@code-asher code-asher deleted the asher/reduce-polling branch October 14, 2024 22:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants