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.

Solutions

  1. Return the initialized watcher reference from ensure_poll_watcher so no second lock/expect is needed
  2. On None, call ensure_poll_watcher again and propagate its error rather than panicking
  3. 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@916fc2b8cb (2026-08-20). Data as JSON: /api/errors/ed6612acfecfe31b. Report an issue: GitHub.

Appendix: source

Thrown at crates/fs/src/fs_watcher.rs:990

            .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)
                    if self.kind == OsWatcherKind::Native && is_max_files_watch_error(&error) =>
                {
                    self.start_native_watch_limit_cooldown(path.as_path());
                    return Ok(None);
                }
                Err(error) => return Err(error),
            }
            state = self.state.lock();
        }

        let id = state.last_registration;
        state.last_registration = WatcherRegistrationId(id.0 + 1);

        let registration_state = WatcherRegistrationState {
            callback: Arc::new(cb),

View on GitHub (pinned to 916fc2b8cb)