zed-industries/zed · error
Restore all never panics
Error message
Restore all never panics
What it means
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.
Source
Thrown at crates/fs/src/fs.rs:1420
let trashed_entry = self
.trash
.lock()
.get(trash_id)
.cloned()
.ok_or(TrashRestoreError::AlreadyRestored)?;
let restored_item_path = trashed_entry.original_parent.join(&trashed_entry.name);
let (tx, rx) = futures::channel::oneshot::channel();
std::thread::Builder::new()
.name("restore trashed item".to_string())
.spawn(move || {
let res = trash::restore_all([trashed_entry.into_trash_item()]);
tx.send(res)
})
.expect("The OS can spawn a threads");
rx.await.expect("Restore all never panics")?;
self.trash.lock().remove(trash_id);
Ok(restored_item_path)
}
}
#[cfg(not(any(target_os = "linux", target_os = "freebsd")))]
impl Watcher for RealWatcher {
fn add(&self, _: &Path) -> Result<()> {
Ok(())
}
fn remove(&self, _: &Path) -> Result<()> {
Ok(())
}
}
#[cfg(feature = "test-support")]
pub struct FakeFs {View on GitHub (pinned to 9d272b0363)
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
Defensive patterns
Strategy: fallback
When it happens
Trigger: Thrown at crates/fs/src/fs.rs:1380 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/1582b6408cc804b5.
Report an issue: GitHub.