Fix progress token is already registered crash

After we started reporting progress when running cargo check during
loading, it is possible to crash the client with two identical progress
tokens.

This points to a deeper issue: we might be running several cargo checks
concurrently, which doesn't make sense.

This commit linearizes all workspace fetches, making sure no updates are
lost.

As an additional touch, it also normalizes progress & result reporting,
to make sure they stand in sync.
This commit is contained in:
Aleksey Kladov 2021-01-10 18:02:02 +03:00
parent 77362c7173
commit 2ed258ba42
5 changed files with 57 additions and 12 deletions

View file

@ -22,6 +22,7 @@ use crate::{
from_proto,
line_endings::LineEndings,
main_loop::Task,
op_queue::OpQueue,
reload::SourceRootConfig,
request_metrics::{LatestRequests, RequestMetrics},
thread_pool::TaskPool,
@ -78,6 +79,7 @@ pub(crate) struct GlobalState {
pub(crate) source_root_config: SourceRootConfig,
pub(crate) proc_macro_client: Option<ProcMacroClient>,
pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
pub(crate) fetch_workspaces_queue: OpQueue,
latest_requests: Arc<RwLock<LatestRequests>>,
}
@ -130,6 +132,7 @@ impl GlobalState {
source_root_config: SourceRootConfig::default(),
proc_macro_client: None,
workspaces: Arc::new(Vec::new()),
fetch_workspaces_queue: OpQueue::default(),
latest_requests: Default::default(),
}
}