Kb/wasm panics (#35319)
Follow-up of https://github.com/zed-industries/zed/pull/34208
Closes https://github.com/zed-industries/zed/issues/35185
Previous code assumed that extensions' language server wrappers may leak
only in static data (e.g. fields that were not cleared on deinit), but
we seem to have a race that breaks this assumption.
1. We do clean `all_lsp_adapters` field after
https://github.com/zed-industries/zed/pull/34334 and it's called for
every extension that is unregistered.
2. `LspStore::maintain_workspace_config` ->
`LspStore::refresh_workspace_configurations` chain is triggered
independently, apparently on `ToolchainStoreEvent::ToolchainActivated`
event which means somewhere behind there's potentially a Python code
that gets executed to activate the toolchian, making
`refresh_workspace_configurations` start timings unpredictable.
3. Seems that toolchain activation overlaps with plugin reload, as
`2025-07-28T12:16:19+03:00 INFO [extension_host] extensions updated.
loading 0, reloading 1, unloading 0` suggests in the issue logs.
The plugin reload seem to happen faster than workspace configuration
refresh in
c65da547c9/crates/project/src/lsp_store.rs (L7426-L7456)
as the language servers are just starting and take extra time to respond
to the notification.
At least one of the `.clone()`d `adapter`s there is the adapter that got
removed during plugin reload and has its channel closed, which causes a
panic later.
----------------------------
A good fix would be to re-architect the workspace refresh approach, same
as other accesses to the language server collections.
One way could be to use `Weak`-based structures instead, as definitely
the extension server data belongs to extension, not the `LspStore`.
This is quite a large undertaking near the extension core though, so is
not done yet.
Currently, to stop the excessive panics, no more `.expect` is done on
the channel result, as indeed, it now can be closed very dynamically.
This will result in more errors (and backtraces, presumably) printed in
the logs and no panics.
More logging and comments are added, and workspace querying is replaced
to the concurrent one: no need to wait until a previous server had
processed the notification to send the same to the next one.
Release Notes:
- Fixed warm-related panic happening during startup
This commit is contained in:
parent
7be1f2418d
commit
49b75e9e93
2 changed files with 69 additions and 55 deletions
|
@ -106,7 +106,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn language_server_initialization_options(
|
||||
|
@ -131,7 +131,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn language_server_workspace_configuration(
|
||||
|
@ -154,7 +154,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn language_server_additional_initialization_options(
|
||||
|
@ -179,7 +179,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn language_server_additional_workspace_configuration(
|
||||
|
@ -204,7 +204,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn labels_for_completions(
|
||||
|
@ -230,7 +230,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn labels_for_symbols(
|
||||
|
@ -256,7 +256,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn complete_slash_command_argument(
|
||||
|
@ -275,7 +275,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn run_slash_command(
|
||||
|
@ -301,7 +301,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn context_server_command(
|
||||
|
@ -320,7 +320,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn context_server_configuration(
|
||||
|
@ -347,7 +347,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn suggest_docs_packages(&self, provider: Arc<str>) -> Result<Vec<String>> {
|
||||
|
@ -362,7 +362,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn index_docs(
|
||||
|
@ -388,7 +388,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn get_dap_binary(
|
||||
|
@ -410,7 +410,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
async fn dap_request_kind(
|
||||
&self,
|
||||
|
@ -427,7 +427,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn dap_config_to_scenario(&self, config: ZedDebugConfig) -> Result<DebugScenario> {
|
||||
|
@ -441,7 +441,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
|
||||
async fn dap_locator_create_scenario(
|
||||
|
@ -465,7 +465,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
async fn run_dap_locator(
|
||||
&self,
|
||||
|
@ -481,7 +481,7 @@ impl extension::Extension for WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
})
|
||||
.await
|
||||
.await?
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -761,7 +761,7 @@ impl WasmExtension {
|
|||
.with_context(|| format!("failed to load wasm extension {}", manifest.id))
|
||||
}
|
||||
|
||||
pub async fn call<T, Fn>(&self, f: Fn) -> T
|
||||
pub async fn call<T, Fn>(&self, f: Fn) -> Result<T>
|
||||
where
|
||||
T: 'static + Send,
|
||||
Fn: 'static
|
||||
|
@ -777,14 +777,15 @@ impl WasmExtension {
|
|||
}
|
||||
.boxed()
|
||||
}))
|
||||
.unwrap_or_else(|_| {
|
||||
panic!(
|
||||
.map_err(|_| {
|
||||
anyhow!(
|
||||
"wasm extension channel should not be closed yet, extension {} (id {})",
|
||||
self.manifest.name, self.manifest.id,
|
||||
self.manifest.name,
|
||||
self.manifest.id,
|
||||
)
|
||||
});
|
||||
return_rx.await.unwrap_or_else(|_| {
|
||||
panic!(
|
||||
})?;
|
||||
return_rx.await.with_context(|| {
|
||||
format!(
|
||||
"wasm extension channel, extension {} (id {})",
|
||||
self.manifest.name, self.manifest.id,
|
||||
)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue