{"record":{"id":"1582b6408cc804b5","repo":"zed-industries/zed","slug":"restore-all-never-panics","errorCode":null,"errorMessage":"Restore all never panics","messagePattern":"Restore all never panics","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fs/src/fs.rs","lineNumber":1420,"sourceCode":"        let trashed_entry = self\n            .trash\n            .lock()\n            .get(trash_id)\n            .cloned()\n            .ok_or(TrashRestoreError::AlreadyRestored)?;\n\n        let restored_item_path = trashed_entry.original_parent.join(&trashed_entry.name);\n\n        let (tx, rx) = futures::channel::oneshot::channel();\n        std::thread::Builder::new()\n            .name(\"restore trashed item\".to_string())\n            .spawn(move || {\n                let res = trash::restore_all([trashed_entry.into_trash_item()]);\n                tx.send(res)\n            })\n            .expect(\"The OS can spawn a threads\");\n\n        rx.await.expect(\"Restore all never panics\")?;\n        self.trash.lock().remove(trash_id);\n        Ok(restored_item_path)\n    }\n}\n\n#[cfg(not(any(target_os = \"linux\", target_os = \"freebsd\")))]\nimpl Watcher for RealWatcher {\n    fn add(&self, _: &Path) -> Result<()> {\n        Ok(())\n    }\n\n    fn remove(&self, _: &Path) -> Result<()> {\n        Ok(())\n    }\n}\n\n#[cfg(feature = \"test-support\")]\npub struct FakeFs {","sourceCodeStart":1402,"sourceCodeEnd":1438,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/fs/src/fs.rs#L1402-L1438","documentation":"A channel guard in the spawned restore thread: the thread runs trash::restore_all and sends the result back over a oneshot channel, with .expect('Restore all never panics') on tx.send. The send only fails if the receiving side was dropped — i.e. the caller of restore cancelled/abandoned the future before the thread finished. The restore itself has already happened; only the result delivery fails, so the panic asserts that never occurs.","triggerScenarios":"Thrown at crates/fs/src/fs.rs:1380 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Replace expect with an explicit check: if tx.send(res).is_err() the receiver is gone, so log and let the thread exit quietly","Use a lossy channel or store the result where a later caller can retrieve it if cancellation is expected","Detach the waiting future from cancellation by keeping the rx alive until the thread completes"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}