Repository navigation
cli: one file-identity rule for the in-process file caches - #12440
Conversation
npm stamps the same modification time on every file it writes, so a file it replaces with one of the same size keeps its size and mtime. A cache keyed on those two alone kept serving the old content in a long-lived process. Every in-process file cache now keys on read-record's exported `fileStamp` (size, mtime, ctime and inode): - component discovery: the family members read from a doc, and the doc values (whose private copy of the rule is gone); - module exports: module texts and parsed modules (private copy gone); - theme discovery: static theme and icon descriptor reads; - theme part data read from its cache file, which left out ctime. `fileStamp` is a raw stat that read recording does not see, while the old copies used the recorded `fs.statSync`. Each cache now records its file with `recordContentRead`, as the TypeScript config reader does, so a kept catalog still sees the dependency on a cache hit. An absent descriptor still throws the error a stat gives. Tests: each changed cache reads again a file rewritten with the same size and mtime, and a cache hit still records its file. Each new test fails without the fix.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report🔎 Preview ·
|
There was a problem hiding this comment.
Changes requested: the cache change is sound and its tests prove it, but the release note and the description each claim something the change does not do.
- The changeset says theme part data is now read again "when npm replaces it with a file of the same size and modification time", but npm never writes that cache file and the old key already caught a replacement through its inode; what changes for part data is a rewrite in place that keeps size, mtime and inode, so reword that clause or leave part data out of the note.
- The description says each new test fails without the fix, but
throws for an absent fileintheme-discovery.test.mjspasses on the base because it guards an error the base already threw, so reword that sentence.
Non-blocking: moduleText, parseModule and partData can keep an entry under the absent stamp - when a file appears between the stamp and the read; keeping nothing for - closes that.
Claims and files checked
Review mode: full; reason: no-earlier-review
- Claim (changeset): a long-running process reads a family doc again after npm replaces it with one of the same size and mtime: verified by the new family-doc test, which fails on the base and passes here.
- Claim (changeset): the same for a theme or icon descriptor: verified by the new descriptor test; icon sets and icon definitions read through the same function.
- Claim (changeset): the same for theme part data: false, since the old key held the inode and npm does not write that file.
- Claim: every in-process file cache now keys on the shared
fileStamp: verified in the four changed modules; no private copy of the rule remains among the in-process file caches. - Claim: the part-data key left out ctime: verified (the old key was inode, size and mtime).
- Claim:
fileStampis a raw stat that read recording does not see, while the old copies used the recordedfs.statSync: verified inread-record.mjs. - Claim: each cache records its file with
recordContentRead, as the TypeScript config reader does, so a kept catalog sees the dependency on a cache hit: verified by the four recording tests, which fail on the base and pass here. - Claim: an absent descriptor still throws the error a stat gives: verified (
readStaticDescriptorValuecallsfs.statSyncon an absent stamp; the test passes on both). - Claim: each changed cache reads again a file rewritten with the same size and mtime, and a cache hit still records its file: verified.
- Claim: each new test fails without the fix: false, one of the eight new tests passes on the base.
.changeset/cache-file-stamp.md: finding (part-data clause).packages/cli/api/theme-edit/_parts.mjs: non-blocking note (absent stamp kept).packages/cli/api/theme-edit/theme-census-key.test.mjs: clear.packages/cli/foundation/discovery/component-discovery.mjs: clear.packages/cli/foundation/discovery/component-discovery.test.mjs: clear.packages/cli/foundation/discovery/module-exports.mjs: non-blocking note (absent stamp kept).packages/cli/foundation/discovery/module-exports.test.mjs: clear.packages/cli/foundation/discovery/theme-discovery.mjs: clear.packages/cli/foundation/discovery/theme-discovery.test.mjs: finding (the description's claim about its absent-file test).
… note A file that appears between its stamp and its read was kept under the absent stamp `-`, and served after it was removed again. The module text, parsed module, doc value, descriptor and part data caches now keep nothing for `-`. The changeset now says what changes for the theme part data cache: a rewrite in place that keeps its size and modification time. npm never writes that file, and the old key already caught a replacement.
There was a problem hiding this comment.
Approved pending CI: CI has not finished on this head yet, so the required checks still need to pass before this merges.
The follow-up fixes both points from the last review: the release note now describes the in-place rewrite of the part data cache, and the description says the absent-descriptor test passes on the base too. No cache keeps anything read under the absent stamp any more. The seven new re-read and recording tests fail on the base and pass here.
Claims and files checked
Review mode: incremental; reason: none
- Claim (changeset): a long-running process reads a family doc again after npm replaces it with one of the same size and mtime: verified by
component-discovery.test.mjs:191, which fails on the base and passes here. - Claim (changeset): the same for a theme or icon descriptor: verified by
theme-discovery.test.mjs:588; icon sets and icon definitions read through the same reader. - Claim (changeset): the theme part data cache is read again after an in-place rewrite with the same size and mtime: verified by
theme-census-key.test.mjs:64. - Claim: a cache keyed on size and mtime alone kept serving old content after npm replaced a file: verified (the base's member and descriptor keys used only those two).
- Claim: every in-process file cache now keys on the shared
fileStamp: verified at each call site (component-discovery.mjs:281,:1119,module-exports.mjs:143,:158,theme-discovery.mjs:721,_parts.mjs:758); no private copy remains. - Claim: the part-data key left out ctime: verified (the base key was inode, size and mtime).
- Claim:
fileStampis a raw stat that read recording does not see, while the old copies used the recorded stat: verified inread-record.mjs. - Claim: each cache records its file with
recordContentRead, as the TypeScript config reader does, so a kept catalog sees the dependency on a cache hit: verified by the four recording tests andpackage-tsconfig.mjs:51. - Claim: an absent descriptor still throws the error a stat gives: verified (
theme-discovery.mjs:723,theme-discovery.test.mjs:615). - Claim: each changed cache reads again a file rewritten with the same size and mtime, and a cache hit still records its file, and each of those tests fails without the fix: verified, seven tests fail on the base and pass here.
- Claim: the absent-descriptor test guards kept behavior and passes on the base too: verified.
.changeset/cache-file-stamp.md: clear.packages/cli/api/theme-edit/_parts.mjs: clear.packages/cli/api/theme-edit/theme-census-key.test.mjs: clear.packages/cli/foundation/discovery/component-discovery.mjs: clear.packages/cli/foundation/discovery/component-discovery.test.mjs: clear.packages/cli/foundation/discovery/module-exports.mjs: clear.packages/cli/foundation/discovery/module-exports.test.mjs: clear.packages/cli/foundation/discovery/theme-discovery.mjs: clear.packages/cli/foundation/discovery/theme-discovery.test.mjs: clear.
npm stamps the same modification time on every file it writes, so a file
it replaces with one of the same size keeps its size and mtime. A cache
keyed on those two alone kept serving the old content in a long-lived
process.
Every in-process file cache now keys on read-record's exported
fileStamp(size, mtime, ctime and inode):values (whose private copy of the rule is gone);
fileStampis a raw stat that read recording does not see, while the oldcopies used the recorded
fs.statSync. Each cache now records its filewith
recordContentRead, as the TypeScript config reader does, so a keptcatalog still sees the dependency on a cache hit. An absent descriptor
still throws the error a stat gives.
Tests: each changed cache reads again a file rewritten with the same size and mtime, and a cache hit still records its file. Each of those tests fails without the fix. One more test, an absent descriptor still throws, guards behavior that is kept and passes on the base too.