{"record":{"id":"ed6612acfecfe31b","repo":"zed-industries/zed","slug":"poll-watcher-initialized","errorCode":null,"errorMessage":"poll watcher initialized","messagePattern":"poll watcher initialized","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/fs/src/fs_watcher.rs","lineNumber":1015,"sourceCode":"                self.native_watcher\n                    .lock()\n                    .as_mut()\n                    .expect(\"native watcher initialized\")\n                    .watch(\n                        path,\n                        if cfg!(any(target_os = \"windows\", target_os = \"macos\")) {\n                            notify::RecursiveMode::Recursive\n                        } else {\n                            notify::RecursiveMode::NonRecursive\n                        },\n                    )?;\n            }\n            WatcherMode::Poll => {\n                self.ensure_poll_watcher()?;\n                self.poll_watcher\n                    .lock()\n                    .as_mut()\n                    .expect(\"poll watcher initialized\")\n                    .watch(path, notify::RecursiveMode::Recursive)?;\n            }\n        }\n\n        Ok(())\n    }\n\n    fn unwatch(&self, path: &Path, mode: WatcherMode) -> anyhow::Result<()> {\n        let watcher = match mode {\n            WatcherMode::Native => self\n                .native_watcher\n                .lock()\n                .as_mut()\n                .map(|watcher| watcher.unwatch(path)),\n            WatcherMode::Poll => self\n                .poll_watcher\n                .lock()\n                .as_mut()","sourceCodeStart":997,"sourceCodeEnd":1033,"githubUrl":"https://github.com/zed-industries/zed/blob/f4178619acd0d47ea1f76a2025c42962c6d6638c/crates/fs/src/fs_watcher.rs#L997-L1033","documentation":"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.","triggerScenarios":"Thrown at crates/fs/src/fs_watcher.rs:1015 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f4178619acd0d47ea1f76a2025c42962c6d6638c","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}