Skip to content

Commit c1f3b00

Browse files
committed
fix: ignore disableCache in client
1 parent 8961354 commit c1f3b00

2 files changed

Lines changed: 29 additions & 3 deletions

File tree

crates/vite_task_client/src/lib.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,24 @@ impl Client {
8484
self.send(&Request::IgnoreOutput(&ns))
8585
}
8686

87-
/// Fire-and-forget — see [`Self::ignore_input`].
87+
/// Temporary no-op.
88+
///
89+
/// `disableCache` currently causes too many false opt-outs because tools
90+
/// call it during configuration, before they know whether they will start
91+
/// an uncached operation such as listening on a port or watching the
92+
/// filesystem.
8893
///
8994
/// # Errors
9095
///
91-
/// Returns an error if the request fails to send.
96+
/// This temporary no-op does not currently return errors.
97+
#[expect(
98+
clippy::missing_const_for_fn,
99+
clippy::unnecessary_wraps,
100+
clippy::unused_self,
101+
reason = "temporary no-op preserves the public API until disableCache semantics are redesigned"
102+
)]
92103
pub fn disable_cache(&self) -> io::Result<()> {
93-
self.send(&Request::DisableCache)
104+
Ok(())
94105
}
95106

96107
/// Requests an env value from the runner. Returns `None` if the runner

crates/vite_task_server/tests/integration.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,9 @@ fn single_client_fire_and_forget() {
9393
let client = connect(&envs);
9494
client.ignore_input(OsStr::new(in_path)).unwrap();
9595
client.ignore_output(OsStr::new(out_path)).unwrap();
96+
// Temporary workaround: the client currently ignores disableCache so
97+
// tools cannot opt out at configuration time before they perform the
98+
// operation that actually makes a task uncacheable.
9699
client.disable_cache().unwrap();
97100
flush(&client);
98101
})
@@ -102,6 +105,18 @@ fn single_client_fire_and_forget() {
102105
let outputs: Vec<_> = reports.ignored_outputs.iter().map(|p| p.as_path().as_os_str()).collect();
103106
assert_eq!(inputs, vec![OsStr::new(in_path)]);
104107
assert_eq!(outputs, vec![OsStr::new(out_path)]);
108+
assert!(!reports.cache_disabled);
109+
}
110+
111+
#[test]
112+
fn raw_disable_cache_request_disables_cache() {
113+
let reports = run_with_server(env_map(&[]), |envs| {
114+
let name = &envs[0].1;
115+
let mut stream = connect_raw(name);
116+
send_frame(&mut stream, &Request::DisableCache);
117+
})
118+
.expect("driver returned error");
119+
105120
assert!(reports.cache_disabled);
106121
}
107122

0 commit comments

Comments
 (0)