Repository navigation
test: use async rm for Windows locked-executable temp cleanup - #2210
Merged
Merged
Conversation
Node 24's native rmSync does not retry std::errc::permission_denied and truncates the Windows retry sleep to ~0ms (fixed upstream in nodejs/node#64698), so maxRetries/retryDelay never covered the briefly locked copied node.exe. Async rm retries EPERM with real backoff.
5 tasks done
4 of 5 tasks
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.
Why
ForkSource.opencode.test.ts > keeps a configured CLI sibling Node directory on PATH when forkingflaked on windows-latest (run 43172864375). Its assertions passed, but theafterEachcleanup failed withEPERM, Permission denied: \\?\C:\...\claudian-opencode-fork-*. On Windows the test copiesnode.exeinto the temp directory and runs it, and Windows briefly keeps the just-exited image locked. Teardown already passedmaxRetries: 10, retryDelay: 100to cover this, butrmSyncnever actually retried.Root cause (from Node v24.16.0
src/node_file.cc,RmSync):rmSyncis a nativestd::filesystemimplementation.std::errc::permission_denied. That error is not inRmSync's retryable set, so the call fails on the first attempt.Sleep(i * retryDelay / 1000). WithretryDelay: 100that truncates to about 2 ms total.Both issues are fixed upstream in nodejs/node#64698, which is not in the Node version pinned in
.node-version(24.16.0).fs/promisesrmstill uses the JS rimraf. That path retriesEPERMwithsetTimeout(i * retryDelay), about 5.5 s in total.What Changed
ForkSource.opencode.test.ts:afterEachnow returnsrmfromnode:fs/promises(same options) instead of callingrmSync. The comment explains why only the async path retries.cliBinaryLocator.test.ts: the same one-line change. It has the same guard for the same reason (a copied executable on Windows) and the same ineffectivermSyncretries.Why This Approach
The fix removes the cause: the retry options never took effect. Async
rmwith the same options is already the cleanup used by the DeepSeek and WSL native suites. It also yields to the event loop between attempts instead of blocking the worker.Alternatives considered:
rmSyncnumbers does nothing, because the error is never retried.node.exewith a hardlink or symlink could not be verified without Windows. Hardlinking the running Node image may make deletion fail outright, and symlinks depend on runner privileges. The copy also keeps the test exercising a real sibling runtime.Validation
npm run typecheck,npm run lint: pass.npm run test:uniton both files, 5 consecutive runs on macOS: 17/17 each time. On macOS this only shows the change causes no regression.npm run test:affected -- --base origin/main: 2 files, 17 tests passed.nativeand run in this PR's "Cross-platform tests (windows-latest)" job, which I will check passes (and rerun once). The original flake rate is unknown, so green runs are supporting evidence, not proof.Impact and Follow-ups
Test-only; no production code changes. Once
.node-versionmoves to a Node release that includes nodejs/node#64698, syncrmSyncretries would work again, but the async form stays correct either way.Checklist