zed-industries/zed · error
poll watcher initialized
Error message
poll watcher initialized
What it means
The poll-mode counterpart of the native watcher guard: after ensure_poll_watcher() returns Ok, the code re-locks poll_watcher and expects Some('poll watcher initialized'). It fires only if the just-succeeded initialization did not leave a watcher installed — an internal contradiction or an interleaved teardown — since WatcherMode::Poll dispatch reaches this line only after the ensure call succeeded.
Source
Thrown at crates/fs/src/fs_watcher.rs:1015
self.native_watcher
.lock()
.as_mut()
.expect("native watcher initialized")
.watch(
path,
if cfg!(any(target_os = "windows", target_os = "macos")) {
notify::RecursiveMode::Recursive
} else {
notify::RecursiveMode::NonRecursive
},
)?;
}
WatcherMode::Poll => {
self.ensure_poll_watcher()?;
self.poll_watcher
.lock()
.as_mut()
.expect("poll watcher initialized")
.watch(path, notify::RecursiveMode::Recursive)?;
}
}
Ok(())
}
fn unwatch(&self, path: &Path, mode: WatcherMode) -> anyhow::Result<()> {
let watcher = match mode {
WatcherMode::Native => self
.native_watcher
.lock()
.as_mut()
.map(|watcher| watcher.unwatch(path)),
WatcherMode::Poll => self
.poll_watcher
.lock()
.as_mut()View on GitHub (pinned to f4178619ac)
Solutions
- Return the initialized watcher reference from ensure_poll_watcher so no second lock/expect is needed
- On None, call ensure_poll_watcher again and propagate its error rather than panicking
- Guard the ensure/use pair with a single critical section to eliminate the interleaving window
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/fs/src/fs_watcher.rs:1015 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20).
Data as JSON: /api/errors/ed6612acfecfe31b.
Report an issue: GitHub.