Skip to content

Commit 7d49f24

Browse files
committed
revert: remove cache directory exclusion from fspy tracking
The cache directory should not be special-cased in fspy. Instead, tests that run tools like oxlint should include a .gitignore with 'node_modules' to prevent the tool from traversing the cache directory — matching the setup of real projects.
1 parent fed3a82 commit 7d49f24

3 files changed

Lines changed: 6 additions & 43 deletions

File tree

crates/vite_task/src/session/execute/mod.rs

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use std::{process::Stdio, sync::Arc};
55

66
use futures_util::FutureExt;
77
use tokio::io::AsyncWriteExt as _;
8-
use vite_path::{AbsolutePath, RelativePath};
8+
use vite_path::AbsolutePath;
99
use vite_task_plan::{
1010
ExecutionGraph, ExecutionItemDisplay, ExecutionItemKind, LeafExecutionKind, SpawnCommand,
1111
SpawnExecution,
@@ -56,11 +56,6 @@ struct ExecutionContext<'a> {
5656
/// Base path for resolving relative paths in cache entries.
5757
/// Typically the workspace root.
5858
cache_base_path: &'a Arc<AbsolutePath>,
59-
/// Cache directory path relative to the workspace root.
60-
/// Used to exclude cache directory accesses from fspy tracking (the cache
61-
/// directory is infrastructure, not a task input).
62-
/// `None` when the cache directory is outside the workspace (custom `VITE_CACHE_PATH`).
63-
cache_dir_relative: Option<&'a RelativePath>,
6459
}
6560

6661
impl ExecutionContext<'_> {
@@ -157,14 +152,9 @@ impl ExecutionContext<'_> {
157152
clippy::large_futures,
158153
reason = "spawn execution with cache management creates large futures"
159154
)]
160-
let _ = execute_spawn(
161-
leaf_reporter,
162-
spawn_execution,
163-
self.cache,
164-
self.cache_base_path,
165-
self.cache_dir_relative,
166-
)
167-
.await;
155+
let _ =
156+
execute_spawn(leaf_reporter, spawn_execution, self.cache, self.cache_base_path)
157+
.await;
168158
}
169159
}
170160
}
@@ -194,7 +184,6 @@ pub async fn execute_spawn(
194184
spawn_execution: &SpawnExecution,
195185
cache: &ExecutionCache,
196186
cache_base_path: &Arc<AbsolutePath>,
197-
cache_dir_relative: Option<&RelativePath>,
198187
) -> SpawnOutcome {
199188
let cache_metadata = spawn_execution.cache_metadata.as_ref();
200189

@@ -304,7 +293,6 @@ pub async fn execute_spawn(
304293
&mut stdio_config.stdout_writer,
305294
&mut stdio_config.stderr_writer,
306295
track_result_with_cache_metadata.as_mut().map(|(track_result, _)| track_result),
307-
cache_dir_relative,
308296
)
309297
.await
310298
{
@@ -430,7 +418,6 @@ impl Session<'_> {
430418
reporter: &mut *reporter,
431419
cache,
432420
cache_base_path: &self.workspace_path,
433-
cache_dir_relative: self.cache_dir_relative.as_deref(),
434421
};
435422

436423
// Execute the graph. Leaf-level errors are reported through the reporter

crates/vite_task/src/session/execute/spawn.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use fspy::AccessMode;
1111
use rustc_hash::FxHashSet;
1212
use serde::Serialize;
1313
use tokio::io::{AsyncReadExt as _, AsyncWrite, AsyncWriteExt as _};
14-
use vite_path::{AbsolutePath, RelativePath, RelativePathBuf};
14+
use vite_path::{AbsolutePath, RelativePathBuf};
1515
use vite_task_plan::SpawnCommand;
1616

1717
use crate::collections::HashMap;
@@ -75,7 +75,6 @@ pub async fn spawn_with_tracking(
7575
stdout_writer: &mut (dyn AsyncWrite + Unpin),
7676
stderr_writer: &mut (dyn AsyncWrite + Unpin),
7777
track_result: Option<&mut SpawnTrackResult>,
78-
cache_dir_relative: Option<&RelativePath>,
7978
) -> anyhow::Result<SpawnResult> {
8079
/// The tracking state of the spawned process
8180
enum TrackingState<'a> {
@@ -207,16 +206,6 @@ pub async fn spawn_with_tracking(
207206
continue;
208207
}
209208

210-
// Skip cache directory accesses — the cache directory is infrastructure
211-
// (SQLite DB, last-summary.json), not a task input. Tools like oxlint may
212-
// traverse node_modules/ and read files in the cache directory, which would
213-
// otherwise cause spurious cache misses when those files change between runs.
214-
if let Some(cache_dir) = cache_dir_relative
215-
&& relative_path.as_path().strip_prefix(cache_dir).is_ok()
216-
{
217-
continue;
218-
}
219-
220209
if access.mode.contains(AccessMode::READ) {
221210
path_reads.entry(relative_path.clone()).or_insert(PathRead { read_dir_entries: false });
222211
}

crates/vite_task/src/session/mod.rs

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use reporter::{
1515
summary::{LastRunSummary, ReadSummaryError, format_full_summary},
1616
};
1717
use rustc_hash::FxHashMap;
18-
use vite_path::{AbsolutePath, AbsolutePathBuf, RelativePathBuf};
18+
use vite_path::{AbsolutePath, AbsolutePathBuf};
1919
use vite_select::SelectItem;
2020
use vite_str::Str;
2121
use vite_task_graph::{
@@ -141,11 +141,6 @@ pub struct Session<'a> {
141141
/// processes (e.g., parallel `vp lib` commands) start simultaneously.
142142
cache: OnceCell<ExecutionCache>,
143143
cache_path: AbsolutePathBuf,
144-
/// Cache directory path relative to the workspace root.
145-
/// Used to exclude cache directory accesses from fspy tracking (the cache
146-
/// directory is infrastructure, not a task input).
147-
/// `None` when the cache directory is outside the workspace (custom `VITE_CACHE_PATH`).
148-
cache_dir_relative: Option<RelativePathBuf>,
149144
}
150145

151146
fn get_cache_path_of_workspace(workspace_root: &AbsolutePath) -> AbsolutePathBuf {
@@ -203,12 +198,6 @@ impl<'a> Session<'a> {
203198
let (workspace_root, _) = find_workspace_root(&cwd)?;
204199
let cache_path = get_cache_path_of_workspace(&workspace_root.path);
205200

206-
// Compute the cache directory path relative to the workspace root.
207-
// Used to exclude cache directory accesses from fspy tracking.
208-
// `None` if the cache path is outside the workspace (custom VITE_CACHE_PATH)
209-
// or if stripping the prefix fails.
210-
let cache_dir_relative = cache_path.strip_prefix(&workspace_root.path).ok().flatten();
211-
212201
// Prepend workspace's node_modules/.bin to PATH
213202
let workspace_node_modules_bin = workspace_root.path.join("node_modules").join(".bin");
214203
prepend_path_env(&mut envs, &workspace_node_modules_bin)?;
@@ -225,7 +214,6 @@ impl<'a> Session<'a> {
225214
plan_request_parser: PlanRequestParser { command_handler: callbacks.command_handler },
226215
cache: OnceCell::new(),
227216
cache_path,
228-
cache_dir_relative,
229217
})
230218
}
231219

@@ -557,7 +545,6 @@ impl<'a> Session<'a> {
557545
&spawn_execution,
558546
cache,
559547
&self.workspace_path,
560-
self.cache_dir_relative.as_deref(),
561548
)
562549
.await
563550
{

0 commit comments

Comments
 (0)