{"record":{"id":"efc7f1d5f5a8a923","repo":"zed-industries/zed","slug":"log-buffer-should-be-a-singleton-efc7f1","errorCode":null,"errorMessage":"log buffer should be a singleton","messagePattern":"log buffer should be a singleton","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/language_tools/src/lsp_log_view.rs","lineNumber":549,"sourceCode":"        cx: &mut Context<Self>,\n    ) {\n        self.toggle_rpc_trace_for_server(key.clone(), true, window, cx);\n        let rpc_log = self.log_store.update(cx, |log_store, _| {\n            log_store\n                .enable_rpc_trace_for_language_server(&key)\n                .map(|state| log_contents(&state.rpc_messages, ()))\n        });\n        if let Some(rpc_log) = rpc_log {\n            self.current_server_key = Some(key);\n            self.active_entry_kind = LogKind::Rpc;\n            let (editor, editor_subscriptions) = Self::editor_for_logs(rpc_log, window, cx);\n            let language = self.project.read(cx).languages().language_for_name(\"JSON\");\n            editor\n                .read(cx)\n                .buffer()\n                .read(cx)\n                .as_singleton()\n                .expect(\"log buffer should be a singleton\")\n                .update(cx, |_, cx| {\n                    cx.spawn({\n                        let buffer = cx.entity();\n                        async move |_, cx| {\n                            let language = language.await.ok();\n                            buffer.update(cx, |buffer, cx| {\n                                buffer.set_language(language, cx);\n                            });\n                        }\n                    })\n                    .detach();\n                });\n\n            self.editor = editor;\n            self.editor_subscriptions = editor_subscriptions;\n            cx.notify();\n        }\n","sourceCodeStart":531,"sourceCodeEnd":567,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/language_tools/src/lsp_log_view.rs#L531-L567","documentation":"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.","triggerScenarios":"Thrown at crates/language_tools/src/lsp_log_view.rs:564 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}