Vite Task can panic in the cache/file-access tracking path when user code accesses a malformed path.
This is clearly a bug in user code, but Vite Task should still handle it gracefully instead of panicking.
The failure mode seems to be:
- file access tracking observes a malformed path
- the path is stripped relative to the workspace
RelativePathBuf::new(...) accepts it
RelativePathBuf::clean() makes it non-relative
- Vite Task panics
A minimal example of the kind of access that triggers this on Windows is:
import fs from "node:fs";
fs.readFileSync("foo/C:/bar", "utf8");
Other path shapes that reproduce the same problem:
file:\\C:\\bar
foo\\file:\\C:\\bar
foo/file:/C:/bar
The panic looks like this:
thread 'main' panicked at crates\vite_path\src\relative.rs:84:39:
cleaning a relative path preserves relativity: NonRelative
So the issue seems to be malformed observed paths that are initially accepted as relative, but become non-relative during cleanup.
Expected behavior
Even if user code touches an invalid path, Vite Task should not panic. It should skip the path, mark the task uncacheable, or return a normal error with context.
Vite Task can panic in the cache/file-access tracking path when user code accesses a malformed path.
This is clearly a bug in user code, but Vite Task should still handle it gracefully instead of panicking.
The failure mode seems to be:
RelativePathBuf::new(...)accepts itRelativePathBuf::clean()makes it non-relativeA minimal example of the kind of access that triggers this on Windows is:
Other path shapes that reproduce the same problem:
file:\\C:\\barfoo\\file:\\C:\\barfoo/file:/C:/barThe panic looks like this:
So the issue seems to be malformed observed paths that are initially accepted as relative, but become non-relative during cleanup.
Expected behavior
Even if user code touches an invalid path, Vite Task should not panic. It should skip the path, mark the task uncacheable, or return a normal error with context.