voidzero-dev / voidzero-dev/vite-plus
vp run: a task with no declared `output` is still cached, and the cache hit silently drops its files
- Vorherrschende Sprache
- Rust
- Sterne
- 5.8k
- Forks
- 262
- Ø Merge
- 23 Std. 41 Min.
- Gemergte PRs (30 T.)
- 138
Beschreibung
### Summary
A `run` task that produces files but does not declare `output` is still cached. On a later cache hit, `vp` replays stdout, reports success, and **does not restore the files** — so the artifact is silently missing while the exit status is 0.
Declaring `output` works correctly (files are restored). The problem is that omitting it produces a wrong result rather than a refusal to cache.
### Reproduction
`vite.config.ts`:
```ts
import { defineConfig } from "vite";
export default defineConfig({
run: { tasks: { generate: "node -e \"require('fs').writeFileSync('generated.txt', 'hello')\"" } },
});
```
```console
$ vp run generate
$ node -e "require('fs').writeFileSync('generated.txt', 'hello')"
$ ls generated.txt
generated.txt
$ rm generated.txt
$ vp run generate
$ node -e "require('fs').writeFileSync('generated.txt', 'hello')" ◉ cache hit, replaying
---
vp run: cache hit, 35ms saved.
$ echo $?
0
$ ls generated.txt
ls: generated.txt: No such file or directory
```
Adding `output: ["generated.txt"]` to the task fixes it — the file comes back on a cache hit.
### Expected
`vp` cannot know a task's outputs without a declaration, so the cache hit is unsound by construction. Rather than replaying a hit that silently drops the artifact, it would be better to either not cache a task with no declared `output`, or warn once that the task is being cached with no known outputs.
The current default means a codegen or build step written as a plain string task appears to work, then quietly stops producing anything the moment the cache warms — with a green exit status. That is very hard to attribute; ours surfaced as a CI check that compared a generated file against itself and reported "up to date".
### Secondary: the config error for a mistyped key is not actionable
Reaching `output` took a while because the plural spelling is rejected with:
```
error: Failed to load task graph
* Failed to load task config file for package at ""
* data did not match any variant of untagged enum UserTaskDefinition
```
The message names neither the offending key (`outputs`), the task, nor the accepted fields.
### Environment
- `vp` 0.1.24
- macOS 15 (Darwin 25.4.0), arm64
- Node 26.8.1
Beitragsleitfaden
Rechercherichtung
Reproduziere das Problem aus vite.config.ts mit `vp run generate`, entferne generated.txt zwischen den Läufen und vergleiche das Verhalten mit und ohne `output`. Verfolge den Cache-Hit-Pfad von `vp run` und die Validierung der Aufgabenkonfiguration. Als erledigt gilt, dass eine Aufgabe ohne deklarierte Outputs nicht länger stillschweigend einen erfolgreichen Treffer meldet, während generierte Dateien fehlen, und dass eine falsch geschriebene Output-Konfiguration nachvollziehbar ist, falls dieser Teil behandelt wird.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Bewertung
- Tech-Stack
- node.js, rust, typescript
- Bereich
- build-system, cli
- Issue-Typ
- Bug
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Aktivitätsstatus
- Aktiv
- Klarheit
- Größtenteils klar
- Anfängerfreundlichkeit
- 52/100