Summary
On Windows, the file-watcher (watch_directory) panics on a tokio-rt-worker thread on a regular basis with:
thread 'tokio-rt-worker' (40024) panicked at C:\Users\runneradmin\.cargo\registry\src\cache.avrea.com-e45b643e7c84d5cb\ignore-0.4.25\src\gitignore.rs:232:9:
path is expected to be under the root
The panic is caught by tokio so the server keeps running, but it recurs while a directory is watched (and the offending file event is presumably dropped, so that save may not get incrementally re-indexed).
Environment
- memtrace: 0.7.25 (npm global)
- OS: Windows 11
- Dependency:
ignore 0.4.25 (gitignore.rs:232)
Suspected cause
Looks like a Windows path-prefix mismatch. Indexed repos are stored with the extended-length \\?\ prefix (e.g. \\?\C:\Users\...\repo), but the watch was registered / events arrive with the plain C:\Users\...\repo form. When the Gitignore matcher is rooted with one prefix form and asked to match a path in the other, strip_prefix(root, path) fails and the crate panics with "path is expected to be under the root".
Suggested fix
Canonicalize Windows paths to a single prefix form before feeding them to the ignore crate (make the gitignore root and the incoming event path agree), and/or wrap the gitignore match in catch_unwind so a mismatch degrades to "no match" instead of a worker-thread panic.
Repro
- Index a repo on Windows (path gets stored with
\\?\ prefix).
watch_directory on the plain C:\... path.
- Save files in the repo — panic recurs.
Thanks!
Summary
On Windows, the file-watcher (
watch_directory) panics on atokio-rt-workerthread on a regular basis with:The panic is caught by tokio so the server keeps running, but it recurs while a directory is watched (and the offending file event is presumably dropped, so that save may not get incrementally re-indexed).
Environment
ignore0.4.25 (gitignore.rs:232)Suspected cause
Looks like a Windows path-prefix mismatch. Indexed repos are stored with the extended-length
\\?\prefix (e.g.\\?\C:\Users\...\repo), but the watch was registered / events arrive with the plainC:\Users\...\repoform. When theGitignorematcher is rooted with one prefix form and asked to match a path in the other,strip_prefix(root, path)fails and the crate panics with "path is expected to be under the root".Suggested fix
Canonicalize Windows paths to a single prefix form before feeding them to the
ignorecrate (make the gitignore root and the incoming event path agree), and/or wrap the gitignore match incatch_unwindso a mismatch degrades to "no match" instead of a worker-thread panic.Repro
\\?\prefix).watch_directoryon the plainC:\...path.Thanks!