You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit d56d82d
Browse filesBrowse the repository at this point in the historyBrowse files
fix(cache): reclaim stale filesystem cache files reliably (#21539)
* fix: age unreferenced cache files by recorded time
The cleanup grace period was measured from each file's modification time,
so a cache restore that refreshes mtimes kept resetting it and orphans in
the directory were never expired. Record when a file is first seen
unreferenced and age it from that instead, which survives a restore. The
index backup still ages by mtime because every store rewrites it.
* fix: also age unreferenced cache files by recorded time
Aging orphans only by modification time leaves them forever in caches that
are restored with refreshed mtimes, which is how the directory kept growing
across CI runs. Record when a file is first seen unreferenced and treat
either signal as expired, so a restored cache still shrinks while a cache
that kept its modification times is cleaned on the very first store as
before.
* fix: collect every fully expired pack in one store
Garbage collection was limited to a single pack per store to avoid the cost of
unpacking, so a cache holding many stale packs needed as many builds to shrink.
Dropping a pack whose items all expired needs no unpacking at all, so collect
those in one pass and keep the rate limit only for packs that must be rewritten.
* fix: reword comment so the spellchecker accepts it
* fix: do not trust a recorded time for a just written cache file
A concurrent build sharing the cache directory can reuse a pack name with the
same size, which keeps the recorded time of the previous file and could expire
a file written seconds ago. Ignore the recorded time while a file is that new,
and stop collecting the oldest content when expiry already emptied the items.
Copy file name to clipboardExpand all lines: .changeset/055-cache-cleanup-unused-files.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,4 +2,4 @@
2
2
"webpack": patch
3
3
---
4
4
5
-
Delete no longer referenced files from the filesystem cache directory after storing the cache.
5
+
Delete no longer referenced files from the filesystem cache directory after storing the cache, age them by recorded time so restored caches are cleaned too, and collect every fully expired pack in one store instead of one per build.
0 commit comments