Skip to content

feat: add cache-prune to prune a pnpm store restored from an older lockfile - #216

Draft
hyoban wants to merge 10 commits into
voidzero-dev:mainfrom
hyoban:fix/prune-fallback-store
Draft

hyoban wants to merge 10 commits into
voidzero-dev:mainfrom
hyoban:fix/prune-fallback-store

Conversation

@hyoban

@hyoban hyoban commented Nov 19, 2026 •

Copy link
Copy Markdown
Collaborator

On a lockfile hash miss, the dependency cache restores the newest cache for the same OS and architecture via restore keys, and nothing ever prunes that store. Each lockfile change restores the previous store, the install adds the new packages, and the post step saves the combined store under the new key. Without a cache size limit or a short retention, the store keeps growing.

In langgenius/dify, on Depot runners (Depot's cache is shared by every branch, keeps entries for 14 days, and has no size limit by default), the Linux pnpm store grew to 3.4 GB. A fresh store for the same lockfile is about 385 MB. Restoring it took a median 18s and up to 109s across 237 jobs, while vp install took 2–3s. That added up to roughly 50–75 runner-minutes in 17 hours.

This adds an opt-in cache-prune input. When it is true and a pnpm cache came from a restore key, the post step runs vp pm cache clean (pnpm store prune) before saving, so the saved store keeps only the packages installs on the runner use. Restore-key restores still save download time.

It is off by default because pruning depends on what the job installed: after run-install: false, a --prod install or a --filter install, prune removes packages the lock file still needs. The README says to enable it only in jobs that install every package in the lock file.

The action skips the prune unless vp env current --json reports pnpm 12.16.0 or later. Before 12.16.0, pnpm store prune also removed packages that pnpm copied or cloned into node_modules, which includes packageImportMethod: copy and macOS's default clone (12.16.0 release notes). If pruning fails, the store is saved unpruned. npm, yarn and bun are unchanged.

I ran the built post step against a temp project with pnpm 12.21.0 and a dependency removed after install:

cache-prune Result
false (default) Store untouched (12 files)
true Removed the unused packages (12 → 4 files). A clean reinstall reused the rest

@hyoban hyoban changed the title fix: prune the pnpm store before saving a cache restored from an older lockfile feat: add cache-prune to prune a pnpm store restored from an older lockfile Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant