zed-industries/zed · error
native watcher initialized
Error message
native watcher initialized
What it means
A post-condition guard in the native watch path: ensure_native_watcher() was just called successfully, so the native_watcher field behind the mutex is expected to be Some. The expect fires only if that invariant is broken — ensure_native_watcher succeeded without installing the watcher (a logic contradiction) or another thread tore the watcher down between the two calls. It is an internal consistency check, not an input-driven error.
Solutions
- Have ensure_native_watcher return the &mut watcher it guaranteed, removing the second lock+expect
- Treat None as a retryable state: re-run ensure_native_watcher and try again instead of panicking
- Hold the same lock across ensure + use so teardown cannot interleave
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/fs/src/fs_watcher.rs:1000 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@916fc2b8cb (2026-08-20).
Data as JSON: /api/errors/b182bdc5b38be7a4.
Report an issue: GitHub.
Appendix: source
Thrown at crates/fs/src/fs_watcher.rs:975
self.recursive
}
#[must_use]
fn add(
&self,
path: Arc<std::path::Path>,
case_insensitive: bool,
cb: impl Fn(¬ify::Event) + Send + Sync + 'static,
) -> anyhow::Result<Option<WatcherRegistrationId>> {
let path = SanitizedPath::from_arc(path);
let key = WatchKey::for_registration(&path, case_insensitive);
let mut state = self.state.lock();
let path_already_covered = state
.paths
.covered_by_recursive_ancestor(&path, self.recursive);
let path_already_registered = state.paths.contains(&key);
if !path_already_covered && !path_already_registered {
if self.kind == OsWatcherKind::Native && state.is_native_watch_limit_cooldown_active() {
self.diagnostics.record(|| {
WatchDiagnosticEvent::new(
self.kind,
"watch_skipped",
&[path.as_path().to_owned()],
"Native watch limit cooldown is active; registration will be retried"
.into(),
false,
)
});
return Ok(None);
}
drop(state);
match self.watch(path.as_path()) {
Ok(()) => {}
Err(error)View on GitHub (pinned to 916fc2b8cb)