Repository navigation
fix: flush pending cache writes in integrity tests [ci full-matrix] - #1593
Merged
Merged
Conversation
On macOS, t.testdir() cleanup fails with ENOTEMPTY because the registry-client cache directory still has files with unreleased file descriptors from pending background writes. Await registryClient.cache.promise() to ensure all pending disk writes complete before the test ends and tap attempts to remove the fixture directory. Co-authored-by: Luke Karrys <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
|
| Branch | fix/macos-integrity-test-teardown |
| Testbed | ubuntu-latest |
🚨 1 Alert
| Benchmark | Measure Units | View | Benchmark Result (Result Δ%) | Upper Boundary (Limit %) |
|---|---|---|---|---|
| vlt install: vue & cache-lockfile | Latency seconds (s) | 📈 plot 🚷 threshold 🚨 alert (🔔) | 9.08 s(+10.78%)Baseline: 8.20 s | 9.02 s (100.71%) |
Click to view all benchmark results
| Benchmark | Latency | Benchmark Result milliseconds (ms) (Result Δ%) | Upper Boundary milliseconds (ms) (Limit %) |
|---|---|---|---|
| vlt install: vue & cache-lockfile | 📈 view plot 🚷 view threshold 🚨 view alert (🔔) | 9,081.66 ms(+10.78%)Baseline: 8,197.95 ms | 9,017.74 ms (100.71%) |
| vlt install: vue & cache-lockfile-node-modules | 📈 view plot 🚷 view threshold | 470.61 ms(+0.99%)Baseline: 465.98 ms | 512.58 ms (91.81%) |
| vlt install: vue & clean | 📈 view plot 🚷 view threshold | 13,583.78 ms(-19.04%)Baseline: 16,779.42 ms | 18,457.36 ms (73.60%) |
| vlt install: vue & lockfile | 📈 view plot 🚷 view threshold | 8,850.30 ms(+7.73%)Baseline: 8,215.49 ms | 9,037.04 ms (97.93%) |
usrrname
pushed a commit
that referenced
this pull request
Aug 15, 2026
…1593) ## Summary On macOS, the `registry tarball integrity verification` tests fail during teardown with: ``` ENOTEMPTY: directory not empty, rmdir .../cache/registry-client ``` The issue: `PackageInfoClient` creates a `RegistryClient` whose `Cache` has background disk writes (`#pending` promises). When `t.rejects()` catches the expected EINTEGRITY error, those background writes may still hold open file descriptors. On macOS (which is stricter about file handle timing than Linux), tap's `t.testdir()` cleanup tries to `rmdir` the cache directory before the writes finish, causing ENOTEMPTY. ## Fix Added `await pi.registryClient.cache.promise()` after each corruption test's `t.rejects()` call. This flushes all pending cache disk writes, ensuring file handles are fully released before tap cleans up the fixture directory. The fix is in two subtests: - `extract throws EINTEGRITY when tarball is corrupted` - `tarball() throws EINTEGRITY when tarball is corrupted` No test logic changes — only resource cleanup. ## CI Note PR title includes `[ci full-matrix]` to run macOS CI and verify the fix. Co-authored-by: Luke Karrys <[email protected]> Co-authored-by: vltbaudbot <[email protected]> Co-authored-by: Luke Karrys <[email protected]>
ruyadorno
added a commit
that referenced
this pull request
Sep 24, 2026
…atrix] (#1897) ## What `Test - macOS - 22.x` has been red on every `release` PR run since Sep 23 (#1894 is the fifth in a row) and on 2 of the last 5 pushes to `main`, always with the same shape: ``` # error thrown in teardown not ok N - ENOTEMPTY: directory not empty, rmdir '…/.tap/fixtures/<subtest>/registry-client' ``` A different subtest loses the race each time — 7 distinct ones so far across `package-info/test/{index,capabilities}.ts` and `registry-client/test/{index,revalidate-entry}.ts`, once on Ubuntu too. It is not a macOS regression and not the release bump: `release` is `main` + version strings, and the passing `main` run and the failing #1894 run had the same runner image (`macos-26-arm64` 20260907.0351.1), Node 22.23.3, vlt and lockfile. ## Why `RegistryClient.request()` hands the response to `cache.set()`, which writes to disk in the background (`mkdir` → `writeFile tmp` → `rename`, tracked in `Cache#pending`; `cache.promise()` awaits it). The subtest returns without flushing, `@tapjs/fixture`'s cleanup runs `rimraf(dir)` — native `fs.rm` with `maxRetries: 0` — and when a write lands between its `readdir` and the final `rmdir`, the `rmdir` throws `ENOTEMPTY`. tap rethrows EOF-hook errors onto the parent test, which is where the duplicated subtests and off-by-N `movingRequests` assertions further down the log come from. The slow disks on the arm64 macOS runners just make the interleaving common. #1593 fixed the same thing in the integrity tests in April. #1876 added ~10 subtests that each `client(t)` → fetch → return without flushing, and never ran on macOS before merging (macOS is excluded from the matrix on ordinary PRs). ## The non-obvious part Checked against the repo's tap (`@tapjs/core` 4.5.9, `@tapjs/fixture` / `@tapjs/after` / `@tapjs/after-each` 4.3.11): both `t.testdir()` and `t.teardown()` wrap `t.onEOF` by calling the previous hook first, so hooks run in **registration order**. A `t.teardown()` added after `t.testdir()` runs after the dir is already gone, and so does a parent `t.afterEach()`. That is why `registry-client/test/index.ts`'s `afterEach` flush ("always wait for the cache to resolve before trying to clean up") was not protecting anything — its `forceRevalidate bypasses fresh cache entries` hit the same `ENOTEMPTY` on the v1.1.1 release PR on Sep 20. ## Changes - `package-info/test/index.ts` — the `?stable` block's `client(t)` helper hooks the flush *before* `t.testdir()`, covering all of its subtests at once. - `package-info/test/capabilities.ts` — same helper shape; `client()` now takes the test. The shared-cache test flushes its second client explicitly. - `registry-client/test/index.ts` — the `afterEach` flush moves into a `t.teardown()` hooked before `t.testdir()` in `beforeEach`, so it actually runs first. - `registry-client/test/revalidate-entry.ts` — explicit `await rc.cache.promise()` in the one test there that didn't have it. `[ci full-matrix]` in the title so macOS runs on this PR. ## Verified - `tap` for `package-info` (291/291) and `registry-client` (843/843), `tsc --noEmit`, eslint and prettier on the touched files — on Linux. - Hook ordering, with a 3-case tap test against the same tap version: teardown after `testdir()` → dir already removed; teardown before `testdir()` → dir still present; parent `afterEach` → dir already removed. - Not reproduced on macOS locally (this was investigated from a Linux box); the macOS job on this PR is the real check. ## Evidence — macOS job on code that includes #1876 | run | branch | subtest that hit `ENOTEMPTY` | |---|---|---| | 35929530891 | release | stable › an exact version asks for it too | | 35934073950 | main (#1881) | registry-client `revalidate-entry.ts` › re-requests the representation it was given | | 35934257337 | release | stable › selectors a prerelease can answer… › a dist tag | | 36025411630 | main (#1879) | stable › asks optimistically before the document lands | | 36025652117 | release | stable › selectors… › the any range — and Ubuntu: `capabilities.ts` › reset clears the settled document too | | 36043038907 | release | stable › an exact version asks for it too; stable › selectors… › a bare name | | 36054844431 | release (#1894) | stable › packument() answers with every version | macOS: `main` 3 ✓ / 2 ✗, `release` 0 ✓ / 5 ✗. Unblocks #1894 — `release.yml` re-cuts the release branch on the next push to `main`. Co-authored-by: Ruy Adorno <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
On macOS, the
registry tarball integrity verificationtests fail during teardown with:The issue:
PackageInfoClientcreates aRegistryClientwhoseCachehas background disk writes (#pendingpromises). Whent.rejects()catches the expected EINTEGRITY error, those background writes may still hold open file descriptors. On macOS (which is stricter about file handle timing than Linux), tap'st.testdir()cleanup tries tormdirthe cache directory before the writes finish, causing ENOTEMPTY.Fix
Added
await pi.registryClient.cache.promise()after each corruption test'st.rejects()call. This flushes all pending cache disk writes, ensuring file handles are fully released before tap cleans up the fixture directory.The fix is in two subtests:
extract throws EINTEGRITY when tarball is corruptedtarball() throws EINTEGRITY when tarball is corruptedNo test logic changes — only resource cleanup.
CI Note
PR title includes
[ci full-matrix]to run macOS CI and verify the fix.Co-authored-by: Luke Karrys [email protected]