Skip to content

ignoreOutput on a file a task reads and writes lets a hit replay outputs no run can produce #1023

Not planned

Description

@hyfdev

When a task reads a file, writes it back, and calls ignoreOutput on it, deleting the file still hits the cache.

The hit can't restore the file, because it was never archived, so it replays outputs that came from the deleted content.

Repro with Vite+ 1.8.0 and @voidzero-dev/vite-task-client 0.2.0:

// task.mjs, run as the package script "task": "node task.mjs"
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
import { ignoreOutput } from '@voidzero-dev/vite-task-client';

const state = existsSync('state.json')
  ? JSON.parse(readFileSync('state.json', 'utf8'))
  : { value: 'missing' };
ignoreOutput('state.json');
writeFileSync('state.json', JSON.stringify(state) + '\n');
writeFileSync('result.json', JSON.stringify({ read: state.value }) + '\n');
echo '{"value":"original"}' > state.json
vp run --cache task   # miss
rm state.json
vp run --cache task   # hit

After the hit, state.json is missing and result.json says original. Running the task would have written missing.

This is because the rebuildable files are decided from the raw writes, and ignoreOutput only decides what is archived.

ignoreOutput could also take the path out of the rebuildable set, so the file stays an ordinary input and deleting it misses.

Vite's dep optimizer and its config cache call ignoreInput together with ignoreOutput, so they wouldn't change.

A tool that calls only ignoreOutput on its own cache would miss on a clean checkout instead of hitting.

Void needs this for void.lock.json, a state file its build reads and rewrites when it changes.

Deleting it after a build that rewrote it already hits, and brings back the Cloudflare bindings it held.

A fresh checkout without it only misses because Void's generated files are tracked as inputs, which voidzero-dev/void#636 is about fixing.

Related: #929.

I can send a PR for this.

Activity

  1. hyfdev commented on Dec 3, 2026

    @hyfdev
    Author

    I talked this through with the maintainer, and whether a file is rebuildable is intentionally independent of ignoreOutput.

    I also looked at how Void users would actually hit the case that motivated this.

    void build only rewrites void.lock.json when its Cloudflare settings change, so a cache hit brings back an old lock only when that cached build rewrote it and the lock is missing afterwards.

    Void's docs ask users to commit void.lock.json, and editing it already misses the cache, so users who follow the docs don't run into this.

    That's too narrow to change vite-task for, so I'm closing this along with #1025, and Void will fix voidzero-dev/void#636 on its own side.

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