Automatic output tracking misses files a task renames into place, so a cache hit restores nothing
維護者通常 1 天內回覆
還沒有人認領這個 Issue。
評估
- 難度
- 4/5
- 預估耗時
- 3-5 天
- 新手友好度
- 48/100
- Issue 類型
- 缺陷
- 描述清晰度
- 描述清楚
- 活躍度
- 活躍
- 技術堆疊
- node.js, rust
- 領域
- build-system, tooling
研究方向
Start with crates/fspy_preload_unix/src/interceptions/mod.rs to see how filesystem calls are intercepted, then read crates/vt/src/session/cache/archive.rs to understand how recorded outputs are archived. The issue calls out Linux rename, renameat, and renameat2, plus macOS rename and renameat; done means those renames record the destination so a cache hit restores the renamed file or folder contents.
由索引模型根據 Issue 內容生成。
描述
Written by an AI agent (Claude) on behalf of @jasonkuhrt.
Problem
With automatic output tracking, the default when cache.output is omitted or holds { auto: true }, a task that writes its output somewhere else and then renames it into place gets a cache entry without that output. A cache hit then restores nothing.
Writing to a temporary path and renaming is the standard way to replace a file or a folder atomically. TanStack Router's generator writes its route tree this way: a temp file, then rename (safeFileWrite, router-generator/src/generator.ts L1203-L1277). Our own code generators stage a whole folder and rename it over the old one.
Reproduction on vite-plus 1.4.0, with no remote cache:
// vite.config.ts
import { defineConfig } from 'vite-plus';
export default defineConfig({
run: {
tasks: {
generate: {
command: 'node generate.mjs',
cache: { input: ['generate.mjs'] },
},
},
},
});
// generate.mjs: stages the output, then renames it into place
import { mkdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
rmSync('.staging', { recursive: true, force: true });
mkdirSync('.staging');
writeFileSync('.staging/a.ts', 'export const a = 1;\n');
rmSync('generated', { recursive: true, force: true });
renameSync('.staging', 'generated');
$ vp run generate
$ node generate.mjs
$ ls generated
a.ts
$ rm -rf generated
$ vp run generate
vp run: cache hit, 39ms saved.
$ ls generated
ls: generated: No such file or directory # the hit restored nothing
Replacing the renameSync line with a direct writeFileSync('generated/a.ts', …) makes the same hit restore generated/a.ts.
Cause
fspy records the write to .staging/a.ts. It has no rename interception (fspy_preload_unix/src/interceptions/mod.rs covers access, dirent, open, spawn and stat), so generated/a.ts is never recorded. When outputs are archived, the recorded .staging/a.ts no longer exists and is skipped (archive.rs L29-L34), which leaves the entry empty.
The workaround today is a positive cache.output glob for the destination. But a glob archives whatever matches on disk, including files a previous run left there, so it gives up what automatic tracking gets right.
Proposal: cover the common case, leave the long tail to explicit config
Record a rename's destination as a write:
- A file renamed to
dst:dstis written. - A folder renamed to
dst: every file underdstis written. These can be collected by walkingdstwhen outputs are archived, instead of tracking each file inside.
Covering rename, renameat and renameat2 on Linux and rename and renameat on macOS should catch nearly every atomic-write tool, since that is how Node's fs.rename and most tools' atomic writers move files.
Deliberately out of scope, where users keep declaring cache.output:
RENAME_EXCHANGE;- moving files into place with
link; - platforms or syscalls the interception layer doesn't reach yet.
Cross-filesystem moves need nothing, since they copy and so are already recorded as writes.
Related: #904 covers the cache-hit side, where a hit leaves behind files the cached run did not write.
- 主要語言
- Rust
- 星號
- 480
- 分支
- 50
- 平均合併
- 1 天 5 小時
- 30 天內合併 PR
- 63
環境準備
在瀏覽器裡用你自己的 GitHub 帳號啟動這個專案的開發容器。
- 沒有 Dockerfile 或 Docker Compose 檔案
- 沒有 Pull Request 範本
- 閱讀貢獻指南
從這裡開始
- 先讀完整個 Issue,再讀專案的貢獻指南。
- 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
- Fork 儲存庫,在一個分支上完成修改。
- 送出 Pull Request,並在描述裡引用這個 Issue 編號。
voidzero-dev/vite-task 的其他 Issue
-
難度 5/5 一週以上 新手友好度 35/100
voidzero-dev/vite-task#921 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 56/100
voidzero-dev/vite-task#910 · 1 則留言 ·
維護者通常 1 天內回覆
-
Export OpenTelemetry client spans for the native remote cache可能已有人在做 @jasonkuhrt 今天認領。 未關閉
難度 4/5 3-5 天 新手友好度 25/100
voidzero-dev/vite-task#906 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 56/100
voidzero-dev/vite-task#905 ·
維護者通常 1 天內回覆
-
難度 4/5 3-5 天 新手友好度 55/100
voidzero-dev/vite-task#904 ·
維護者通常 1 天內回覆
查看 voidzero-dev/vite-task 的全部 Issue
相似的 Issue
-
good first issue help wanted r-docs
難度 2/5 1-3 小時 新手友好度 72/100
servo/rust-smallvec#824 ·
維護者通常 1 天內回覆
-
難度 2/5 1-3 小時 新手友好度 83/100
維護者通常 1 天內回覆
-
priority middle
難度 1/5 1 小時以內 新手友好度 62/100
KATO-Hiro/AtCoderClans#12940 ·
維護者通常 1 天內回覆
-
bug
難度 2/5 1-3 小時 新手友好度 83/100
維護者通常 1 天內回覆
-
o8 next debug build aborts on Glass to Dark appearance switch (nil identifier messaged before check)未關閉bug
難度 2/5 1-3 小時 新手友好度 78/100
hurttlocker/o8#5112 ·