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

Aperta
#2,635 1 commento 0 reazioni 0 assegnatari Vedi su GitHub
Lingua principale
Rust
Stelle
5.8k
Fork
262
Merge medio
23h 41m
PR unite (30g)
138

Descrizione

### 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

Guida per i contributori

Apri la guida per i contributori

Direzione di ricerca

Riproduci il problema da vite.config.ts con `vp run generate`, rimuovendo generated.txt tra un’esecuzione e l’altra, e confronta il comportamento con e senza `output`. Traccia il percorso di cache hit di `vp run` e la validazione della configurazione del task. Il lavoro è completato quando un task senza outputs dichiarati non segnala più silenziosamente un hit riuscito omettendo i file generati e quando una configurazione di output digitata erroneamente è utile per intervenire, se quella parte viene affrontata.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
node.js, rust, typescript
Ambito
build-system, cli
Tipo di issue
Bug
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
52/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.