Skip to content

vp run: a task with no declared output is still cached, and the cache hit silently drops its files #2635

Description

@ubugeeei

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:

import { defineConfig } from "vite";

export default defineConfig({
  run: { tasks: { generate: "node -e \"require('fs').writeFileSync('generated.txt', 'hello')\"" } },
});
$ 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 "<path>"
* 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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions