{"record":{"id":"f723f5f9d9816ee5","repo":"rust-lang/rust","slug":"a-receiver-has-been-dropped-something-panicked","errorCode":null,"errorMessage":"A receiver has been dropped, something panicked!","messagePattern":"A receiver has been dropped, something panicked!","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"critical","filePath":"src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs","lineNumber":217,"sourceCode":"                self.fetch_workspaces(cause, path, force_crate_graph_reload);\n            }\n        }\n\n        while let Ok(event) = self.next_event(&inbox) {\n            let Some(event) = event else {\n                anyhow::bail!(\"client exited without proper shutdown sequence\");\n            };\n            if matches!(\n                &event,\n                Event::Lsp(lsp_server::Message::Notification(Notification { method, .. }))\n                if method == lsp_types::ExitNotification::METHOD.as_str()\n            ) {\n                return Ok(());\n            }\n            self.handle_event(event);\n        }\n\n        Err(anyhow::anyhow!(\"A receiver has been dropped, something panicked!\"))\n    }\n\n    fn register_did_save_capability(&mut self, additional_patterns: impl Iterator<Item = String>) {\n        let additional_filters = additional_patterns.map(|pattern| {\n            lsp_types::DocumentFilter::TextDocumentFilter(lsp_types::TextDocumentFilter::Pattern(\n                lsp_types::TextDocumentFilterPattern {\n                    language: None,\n                    scheme: None,\n                    pattern: pattern.into(),\n                },\n            ))\n        });\n\n        let mut selectors = vec![\n            lsp_types::DocumentFilter::TextDocumentFilter(lsp_types::TextDocumentFilter::Pattern(\n                lsp_types::TextDocumentFilterPattern {\n                    language: None,\n                    scheme: None,","sourceCodeStart":199,"sourceCodeEnd":235,"githubUrl":"https://github.com/rust-lang/rust/blob/7088e4b63a9516ebfbfe2ab2d999cf01a528ac14/src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs#L199-L235","documentation":"Returned at the end of the main event loop when next_event returns an error (the crossbeam/lsp_server Receiver was dropped rather than yielding a message). In r-a's design the receiver is held by scheduler threads; a drop indicates one of them panicked, so the loop cannot continue and reports it.","triggerScenarios":"Any panic inside a rust-analyzer task thread that owns the sending side of the event channel — the sender is dropped on unwind, and the main loop's recv() returns Err. Often paired with a panic backtrace earlier in the log.","commonSituations":"A bug in an analysis pass that panics (which r-a's invariants say must not happen); an unwrap on None in a proc-macro or hir path; OOM abort; a stdx::assert failure unwinding.","solutions":["Look earlier in the log for the panic backtrace — that is the real defect; this message is the symptom.","File a rust-analyzer issue with the backtrace and the code that triggered it (r-a must not panic on user code).","Update to a newer rust-analyzer; the panic may already be fixed.","As a workaround, narrow the workspace or disable the feature implicated by the backtrace."],"exampleFix":"// before: opaque message at loop end\nErr(anyhow::anyhow!(\"A receiver has been dropped, something panicked!\"))\n\n// after: capture and forward the last recorded panic so users see the cause\nlet last_panic = std::panic::take_hook(); // or store last panic in a Mutex on hook install\nErr(anyhow::anyhow!(\n    \"A receiver has been dropped, something panicked! \\\n     Last panic: {}\",\n    GLOBAL_LAST_PANIC.lock().unwrap().as_deref().unwrap_or(\"(no backtrace captured)\")\n))","handlingStrategy":"try-catch","validationCode":"// Not preventable by callers — but you can install a panic hook to capture the\n// cause so this terminal error is diagnosable:\nstd::panic::set_hook(Box::new(|info| {\n    *GLOBAL_LAST_PANIC.lock().unwrap() =\n        Some(format!(\"{info}\"));\n}));","typeGuard":"null","tryCatchPattern":"// Catch Anywhere in tasks and convert to a logged error instead of letting the\n// sender drop silently:\nstd::panic::catch_unwind(|| task()).map_err(|p| {\n    tracing::error!(\"task panicked: {p:?}\");\n})?;","preventionTips":["Treat this message as a symptom; investigate the panic backtrace logged earlier.","Keep rust-analyzer current; many panic bugs are fixed quickly.","Report reproducible panics with the backtrace and triggering code."],"tags":["rust-analyzer","panic","lsp","main-loop"],"backgroundTag":null,"analyzedSha":"7088e4b63a9516ebfbfe2ab2d999cf01a528ac14","analyzedAt":"2026-08-10T14:17:03.603Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}