Repository navigation
Description
Written by an AI agent (Antigravity) on behalf of @jasonkuhrt.
Please add an optional mode?: 'off' | 'read' | 'read-write' field to run.cache.remote in workspace config, alongside url and headers.
Motivation
Remote cache configuration in vite.config.ts now supports url and headers (resolver & mode precedence in #727, configured header resolution in #1039, public types and CLI help in #1046, and strict schema / URL validation in #1048, tracked under #930), while keeping mode restricted to VP_REMOTE_CACHE or --remote-cache.
import { defineConfig } from 'vite-plus'
export default defineConfig({
run: {
cache: {
remote: {
url: 'https://cache.example.com/my-project/feature',
mode: 'read-write', // currently rejected: unknown field `mode`, expected `url` or `headers`
},
},
tasks: {
hello: { command: 'echo hello' },
},
},
})For workspaces whose remote-cache policy depends on repo or branch state (for example, read on the default branch and read-write on feature branches or trusted local/CI runs), being able to compute url and headers in vite.config.ts without being able to declare mode there forces an external CLI wrapper or shell hook before vp run starts.
Proposed behavior and precedence
Keep CLI and environment overrides above workspace config, matching how VP_REMOTE_CACHE_URL and VP_REMOTE_CACHE_HEADER_* already override run.cache.remote.url and run.cache.remote.headers:
| Priority | Source |
|---|---|
| 1 (highest) | --remote-cache <mode> CLI flag |
| 2 | VP_REMOTE_CACHE environment variable |
| 3 | run.cache.remote.mode in workspace config |
| 4 (default) | read when a remote endpoint is configured; off otherwise |
- With
run.cache.remote.urlandrun.cache.remote.mode: 'read-write', config loading succeeds (e.g.,vp run --dry-run --json helloaccepts the config and emits a plan instead of failing schema validation), and a cacheable task run usesread-writeremote cache access without requiringVP_REMOTE_CACHE=read-writeor--remote-cache read-write. - Setting
mode: 'read'ormode: 'read-write'without any configured endpoint (urlorVP_REMOTE_CACHE_URL) should preserve the existing missing-endpoint error (crates/vt_plan/src/remote_cache.rs:193-201). - Invalid values in
run.cache.remote.modeshould fail config validation with the sameoff/read/read-writeexpectation used forVP_REMOTE_CACHE.
Standalone reproduction on vite-plus@1.9.0 and source references on main (0455423)
Tested on macOS ARM64, Node 24.22.2, unpatched vite-plus@1.9.0 (bundling Vite Task 69ff9fcbde1bff9ec05b733dddcd86972cbc9eb9). Source references verified on origin/main at 0455423a406ed4343207ac46dd6eef34435110ae.
Setup (from an empty directory)
package.json:
{"name":"vite-plus-upstream-repro","private":true,"type":"module","devDependencies":{"vite-plus":"1.9.0"}}Install with npm install, then create cache-mode/package.json and cache-mode/vite.config.ts, and run git init --quiet inside cache-mode/:
cache-mode/package.json
{"name":"cache-mode","private":true,"type":"module"}cache-mode/vite.config.ts
import { defineConfig } from 'vite-plus'
export default defineConfig({
run: {
cache: {
remote: { url: 'http://127.0.0.1:1/cache', mode: 'read-write' },
},
tasks: {
hello: { command: 'echo hello' },
},
},
})Command & observed stderr (run from cache-mode/, exit code 1, empty stdout):
$ env -u VP_REMOTE_CACHE -u VP_REMOTE_CACHE_URL ../node_modules/.bin/vp run --dry-run --json hello
error: Failed to load task graph
* Failed to load task config file for package at /private/tmp/vite-plus-upstream-repro/cache-mode/
* unknown field `mode`, expected `url` or `headers`Expected result (with this proposal): the dry run accepts run.cache.remote.mode and emits a plan for hello (exit code 0), and a cacheable task run applies read-write remote cache mode without needing VP_REMOTE_CACHE or --remote-cache.
Source references (0455423a406ed4343207ac46dd6eef34435110ae)
- Remote cache config schema (denies unknown fields):
crates/vt_graph/src/config/user.rs:472-506 - CLI
--remote-cacheflag plumbing into run env:crates/vt_plan/src/plan.rs:773-783 - Mode resolution from
VP_REMOTE_CACHEand missing-endpoint error:crates/vt_plan/src/remote_cache.rs:163-207
Metadata
Metadata
Assignees
Labels
Type
Fields
Priority
Activity