Repository navigation
fix(tools): close the async test-cleanup invariant's gaps, and stop asserting one Node version's rmSync bug - #632
Merged
Conversation
…eanup invariant The check now sees an alias taken from require, an optional call and bracket access with a literal key, counts the exemption marker only inside a comment, reads an apostrophe in JSX text as text, and walks .jsx files as its spec filter already expected. The Windows test of the synchronous form no longer asserts a timing that only held before Node 24.21, where rmSync started to retry with real delays while blocking the event loop. It now holds the directory until a release the test schedules, which cannot run during the synchronous call on any version.
Contributor
Author
|
Review attestation: ready to merge at A push to this PR makes this attestation stale; the new head needs its own review. |
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.
Fixes #629. Refs #563, #622.
This also fixes the
verify (windows-latest, node 24)failure seen on PRs #627 and #630, intools/test/test-cleanup-retries.spec.ts: fails at once in the synchronous form, though it asks for retries (expected 6628 to be less than 500on #630,expected 6606 to be less than 500on #627).The CI failure: not a flake, a Node change
rmSync(held, { maxRetries, retryDelay: 100 })does on WindowsrimrafEBUSYat once;EBUSYis not retriedRmSyncEPERMat once: a held directory comes back aspermission_denied, which was not in the retryable set, and the Windows wait wasSleep(i * retryDelay / 1000), which is 0 mssetup-nodewithnode-version: 24resolved to v24.21.0)RmSyncpermission_deniedbecame retryable and the wait becameSleep(i * retryDelay)in millisecondsThe change is nodejs/node#64698 (commit
b269616936, "fs: treatstd::errc::permission_deniedasEPERMerror"), which fixes nodejs/node#64016 and first shipped in v24.21.0. It is not in v25.0.0 or v25.2.0. WithmaxRetries: 10, retryDelay: 100, the waits add up to 5.5 s, which with the attempts matches the 6.6 s CI saw.So the old test asserted one Node version's bug. The invariant still holds, for an accurate reason:
Sleepruns on the main thread, so the event loop stands still for the whole budget. No timer fires and no child's exit is handled during it, so a hold the test process itself would release is never released.fs.promises.rmretries on every supported version without blocking.The test now holds the directory with a child process and schedules the release from the test's own event loop 100 ms in, well inside the retry budget (
maxRetries: 4, retryDelay: 100, so 1 s of waits on 24.21). The synchronous call blocks the event loop, so the release cannot run during it on any version: it throwsEPERM/EBUSYand the directory is still there. There is no wall-clock assertion left. The existing test beside it still shows thatremoveTestDirectory()waits out the same kind of hold and removes the directory.The module's doc comment, its failure message, and the doc comment of
removeTestDirectory()intools/test-cleanup.tsnow state this reason instead of "never retries".docs/does not repeat the claim.The gaps from #629
In
tools/invariants/test-cleanup-retries-asynchronously.mjs:const x = require("node:fs").rmSync.rmSync.fs.rmSync?.(...)?.before its(. An alias is not taken from an optional call either.fs["rmSync"](...),const x = fs["rmSync"]",'or`) is rewritten to.rmSync, padded to the same length, where the brackets and quotes are code. The same text inside a string or a comment is left alone.<p>Don't</p>hiding a later call'or"right after a letter, digit,_or$cannot open a string in code, so it is read as an apostrophe. A quote in JSX text after a space or a tag (<p>It is 'odd</p>) still opens a string. That remaining case is listed under the module's known limits, next to the regular-expression-literal limit..spec.jsxaccepted,.jsxnever walked.jsxis included. No.jsxfile exists in the repo today.The object-key nit (
{ rmSync: spy }makesspyan alias) is unchanged. The issue calls it harmless: it can only add a name, never hide a call.Tests
Six new tests in
tools/test/test-cleanup-retries.spec.ts, one per gap. The.jsxtest runs the check'srun()over a temporary tree.All six fail against
main's module. The spec was run with onlytools/invariants/test-cleanup-retries-asynchronously.mjschecked out fromorigin/main(Windows 11, Node v24.11.0):mainexpected [] to deeply equal [ 3, 4 ]expected [] to deeply equal [ 1, 2 ]expected [] to deeply equal [ 1, 2, 5 ]expected [] to deeply equal [ 2, 3 ]expected [] to deeply equal [ 1, 2 ]expected [] to deeply equal [ 'apps/web/src/view.spec.jsx', …(1) ]Verification (Windows 11)
tools/test/test-cleanup-retries.spec.ts, Node v24.11.0, 6 runspnpm invariantspnpm typecheckeslinton the 3 changed filespnpm verifyOverlap with open PRs
No open PR touches these three files. #631 (#626) changes production
rmSyncsites inapps/runtime, outside this check's scope.