zed-industries/zed · error
log buffer should be a singleton
Error message
log buffer should be a singleton
What it means
Asserts that the LSP log buffer, obtained while building the RPC-trace view for a language server, is the unique open entity of its kind. It fires if open_buffer returned an entity that the global buffer store did not recognize as the singleton log buffer — i.e., the log buffer was created outside the expected singleton path or the store was reset between view creations.
Source
Thrown at crates/language_tools/src/lsp_log_view.rs:549
cx: &mut Context<Self>,
) {
self.toggle_rpc_trace_for_server(key.clone(), true, window, cx);
let rpc_log = self.log_store.update(cx, |log_store, _| {
log_store
.enable_rpc_trace_for_language_server(&key)
.map(|state| log_contents(&state.rpc_messages, ()))
});
if let Some(rpc_log) = rpc_log {
self.current_server_key = Some(key);
self.active_entry_kind = LogKind::Rpc;
let (editor, editor_subscriptions) = Self::editor_for_logs(rpc_log, window, cx);
let language = self.project.read(cx).languages().language_for_name("JSON");
editor
.read(cx)
.buffer()
.read(cx)
.as_singleton()
.expect("log buffer should be a singleton")
.update(cx, |_, cx| {
cx.spawn({
let buffer = cx.entity();
async move |_, cx| {
let language = language.await.ok();
buffer.update(cx, |buffer, cx| {
buffer.set_language(language, cx);
});
}
})
.detach();
});
self.editor = editor;
self.editor_subscriptions = editor_subscriptions;
cx.notify();
}
View on GitHub (pinned to 5a9b9558db)
Solutions
- Ensure the log buffer is only ever created through the singleton helper that registers it with the buffer store
- Reuse a cached entity handle for the log buffer instead of re-opening by path
- Replace the expect with a fallback that creates a fresh buffer when uniqueness cannot be established
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/language_tools/src/lsp_log_view.rs:564 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@5a9b9558db (2026-08-20).
Data as JSON: /api/errors/efc7f1d5f5a8a923.
Report an issue: GitHub.