Repository navigation
test(analyze-pr): the reach test keeps its fixture out of the system temporary directory (re-land of #9209) - #9212
Conversation
…temporary directory Each analyze-pr run in "sizes a component whose bundle reaches a changed shared module" bundles with esbuild, which reads the listing of every directory above the files it bundles. The fixture and analyze-pr's scratch files lived in the system temporary directory, so every build listed it. On a shared machine it held 272,514 entries, and under load the test ran past its 30 s limit, though it passes alone in about 2 s. The fixture and the scratch directory (TMPDIR for the analyze-pr runs it starts) now live under the checkout's node_modules/.cache/analyze-pr-test. On two cores shared with 20 busy processes the test ran 34.2 to 43.9 s before (5 of 5 timed out) and 12.5 to 19.4 s after (7 of 7 passed). No timeout, retry or skip changes; analyze-pr.js is unchanged.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
PR Analysis Report
Generated by PR Enrichment workflow | View current CI run |
There was a problem hiding this comment.
Looks good: the reach test's fixture and analyze-pr's scratch files now live under node_modules/.cache, the test's assertions and 30 s limit are unchanged, and all 11 tests in the file pass. With a 250,000-entry temporary directory the reach test drops from about 1.1 s to 0.5 s, the same as with an empty one. As a follow-up, the four other tests in this file that bundle under os.tmpdir() (for example measures ESM entries by module type…) keep the same exposure, as #9209 noted; consider restoring that note in the description.
[Automated review]
…sumer project (#9223) ## Maintainer impact Each run of `internal/shadcn-registry/generate-shadcn-registry.test.mjs`, which is part of `pnpm test:node`, leaves 16 directories in the system temporary directory. `verify-full-catalog.mjs` leaves one for every file ShadCN transforms. On a shared machine that runs these often, the temporary directory held 187,072 `shadcn-*` directories, and every tool that reads that directory's listing slowed down (that size is what timed out the analyze-pr test fixed in #9212). ## Intended invariant The test and the catalog verifier check what they checked before, and leave nothing behind in the system temporary directory. ## Change The pinned ShadCN client, 4.19.0, makes an empty temporary directory (`mkdtemp(path.join(tmpdir(), "shadcn-"))`) for each file it transforms during `shadcn add` and never removes it. Both callers now give it a `TMPDIR` inside the consumer project they already create and remove in `finally`: the test's five `shadcn add` runs, and `runShadcn` in `verify-full-catalog.mjs`. The test also removes its no-op package-manager directory in `afterAll`; it was made once per run and never removed. Upstream origin: ShadCN's transform step in 4.19.0. 4.22.1, which #8750 bumps to, no longer makes these in its transform step, but its icons step still makes one. This change keeps whatever ShadCN makes inside the project either way. Nothing is filed upstream. ## Evidence - Failure before the change: with `TMPDIR` pointed at an empty directory, one run of the test file (29 tests pass) left 15 `shadcn-*` directories and 1 `astryx-noop-pm-*`. One run of `verify-full-catalog.mjs` over a 12-item catalog (18 installed files per mode, in TypeScript and JavaScript) left 60 `shadcn-*`. - Success after the change: the same runs left none: 0 and 0 from the test file (29 tests pass), and 0 from the verifier over the same catalog (it passes). Node's own `node-compile-cache` directory appears in both runs: a cache Node reuses, not one per run. - Product/runtime behavior verified unchanged: test and CI verifier only. ## Scope - [x] No intended public API, product behavior, visual direction, or policy change. - [x] Product changes discovered during the work were removed or split. - [x] Public text and artifacts contain no internal Meta context. ## Testing - Leftovers counted with `TMPDIR=<empty directory> pnpm exec vitest run --project node internal/shadcn-registry/generate-shadcn-registry.test.mjs`, and with `TMPDIR=<empty directory> node internal/shadcn-registry/verify-full-catalog.mjs` after `pnpm build` and `DOCSITE_TARGET=canary node apps/docsite/scripts/generate-data.mjs`, as CI runs it. The verifier ran over a 12-item subset of the 1,036-item canary catalog (4 components, 2 hooks, 4 examples, 2 templates; `registry.json` cut to them and restored afterwards), because the whole catalog was too heavy for a shared machine. - Local gates at 92ba203 (one commit on main dade717): build, typecheck and repo checks pass; the ShadCN registry tests and the CI contract test for the verifier pass (36); the node suite passes except the two `cache.test.mjs` lock tests that fail on this machine without the change too (#8520).
Re-lands #9209 by @vjeux unchanged: the same commit, with his authorship. A fork pull request that changes
.github/doesn't run CI here, so it lands from this branch.Maintainer impact
On a busy machine, the analyze-pr reach test could run past its 30 s limit. The cause wasn't the test's work: esbuild reads the listing of every directory above a file it bundles, and the system temporary directory on a shared machine can hold hundreds of thousands of entries. The test now keeps its fixture and analyze-pr's scratch files under the checkout's
node_modules/.cache, so contributors stop seeing a time-out that has nothing to do with their change.Intended invariant
Change
.github/scripts/analyze-pr.test.mjs: the reach fixture lives undernode_modules/.cache/analyze-pr-test/reach-*/with its ownTMPDIR, and is removed afterwards. Its four analyze-pr runs share one helper.Evidence
Scope
Testing
vitest run --project node .github/scripts/analyze-pr.test.mjs