vfs-notify drops notify's rescan event on Linux inotify queue overflow, leaving server-side file state stale
rust-analyzer version: rust-analyzer 0.3.3113-standalone (2026-11-09)
rustc version: rustc 1.99.1 (58cf8f9c3 2026-10-13)
editor or extension: Minimal custom LSP client script on Linux
relevant settings:
{
"rust-analyzer.files.watcher": "server"
}
(Only affects server-side watching; the default "client" mode is not involved.)
repository link: rust-analyzer-server-watcher-overflow
code snippet to reproduce:
// src/lib.rs
mod value;
pub fn get() -> u32 {
value::VALUE
}
// src/value.rs
pub const VALUE: u32 = 1111;
Steps to reproduce / Observed behavior
On Linux 7.3.3 (Fedora 44) with the default inotify queue limit (fs.inotify.max_queued_events = 16384)::
- Start
rust-analyzerwithfiles.watcher = "server"on a crate containing the files above. - Open only
src/lib.rsand confirm hover onvalue::VALUEshows1111. - Update
src/value.rson disk topub const VALUE: u32 = 2222;and confirm hover follows and shows2222(control: a plain edit is picked up). - Pause the
rust-analyzerprocess (SIGSTOP). - Create 20480 new files in
src/(exceeding the 16384 queue limit), then updatesrc/value.rson disk topub const VALUE: u32 = 3333;. - Resume the
rust-analyzerprocess (SIGCONT).
Result:
- Hover on
value::VALUEinsrc/lib.rsstill shows2222. - Creating or touching another file in
src/afterwards does not recover the stale state. - Restarting
rust-analyzershows3333. - Control: repeating the exact same steps with 200 new files instead of 20480 updates hover to
3333as expected. Both cases (20480 and 200) were run 3 times with identical results.
Cause
When the kernel inotify queue overflows, it drops further events and queues an overflow record. The notify crate converts that record into an event with EventKind::Other and the rescan flag (event.need_rescan() == true).
In crates/vfs-notify/src/lib.rs (master at 8ba7bef, linked below), vfs-notify only acts on Create, Modify, Remove, and Access(Open), and need_rescan does not appear anywhere in the file. As a result, the overflow notification is silently ignored and files whose events were dropped retain stale contents.
https://github.com/rust-lang/rust-analyzer/blob/8ba7bef996a21ee8157d13f141b0525b092a9872/crates/vfs-notify/src/lib.rs#L201-L204
Possible fix
When event.need_rescan() is true, reload the watched entries as done on start-up (and report any changed files).
Scope / Not checked
- Editor-side watchers (
files.watcher = "client", the default). - macOS and Windows (though
notifysets the same rescan flag when FSEvents drops events on macOS). - How frequently inotify queue overflows occur in everyday editing workflows.
Assisted by Anthropic Claude Fable 5.2
Yes I do, and this comment is not generated by AI. I wrote assist by Claude Fable 5.2 because during the process of finding the bug, I used the AI model.
Sorry but this is not a bug. If you have too many watched files you need to increase the limit. Furthermore I highly doubt you really have a workspace with 20,000 files, so this seems like a highly artificial report which is not always welcome.
I might accept a fix if either:
- We'll get report of people actually hitting this regularly in the wild (very unlikely), or
- The diff is no more than a few lines.