Skip to content

[Windows] Panic in cache path tracking when a malformed observed path reaches RelativePathBuf::clean() #325

@SegaraRai

Description

@SegaraRai

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:

  1. file access tracking observes a malformed path
  2. the path is stripped relative to the workspace
  3. RelativePathBuf::new(...) accepts it
  4. RelativePathBuf::clean() makes it non-relative
  5. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions