Repository navigation
test: harden all recursive rmSync teardowns with retry options - #1655
Conversation
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1610-pr.1655.92d3297This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1655.tgz
npm install -g packageInstall instructions are refreshed on each push. |
Bare rmSync(dir, {recursive, force}) in test teardowns throws ENOTEMPTY on
loaded CI runners when a spawned child recreates entries between readdir and
rmdir (observed: issue1086-chain T3 on ubuntu-latest Node 22, run
36520549393). Node's rimraf only retries transient errors when maxRetries is
set, so a shared tests/tmp-rm.ts rmrf() with maxRetries:10/retryDelay:50 now
replaces all 354 bare recursive teardown calls across 91 test files, matching
the precedent already at issue1086-chain-self-exemption.test.ts:663. Orphaned
named rmSync imports dropped where no longer used. Test-only change.
The mechanical rmSync->rmrf replacement dropped the space after the closing brace in 44 node:fs import lines ('writeFileSync }from'). Valid TS, wrong style; pure formatting fix.
09dca22 to
7480989
Compare
[bot] 🏷 Review of PR #1655 (in progress — interim report) Pulled the branch and audited it against the description before touching anything. Description claims — all verified against the actual diff:
Two problems found and fixed directly on the PR branch:
Fresh pre-flight on the rebased head (
Pushed to the PR branch. CI is currently running on 中文摘要:审查了本 PR(teardown rmSync 加重试选项),发现并修复了机械替换丢空格(44 文件)和 rebase 后 master 新增的 15 处同款裸 rmSync,本地全量预检通过,等 CI 全绿即可合并。 |
[bot] 🏷 Review complete — CI fully green, ready to merge ① Original issue direction (#1646): correct root cause. The defect producer is the bare recursive ② Regression audit — existing behaviors touched by the diff: the diff is 100% under ③ Code review: ④ Test validity: the gate is the real thing — full suite across the whole CI matrix (ubuntu 22/24, windows 22/24) plus e2e lanes, i.e. the loaded-runner environments where the race lives. All green below. ⑤ Diff cleanliness: clean — one linear history, every line serves the PR's purpose. My two additions are clearly-labeled in-scope fixes: the 44-file Final state on head
Merging stays human-only per repo rules — #1655 中文摘要:审查并加固了本 PR(teardown rmSync 加 maxRetries 重试):修了机械替换丢空格(44 文件)、rebase 到最新 master 并补转 zcode 新增的 15 处同款裸 rmSync,本地与 CI(含 Windows 矩阵)全绿,可以合并。 |
…1655 hardening dropped the import but missed this call) Drive-by fix for a pre-existing master breakage found while reviewing PR #1703: master's CI is red because this finally block calls rmSync, which #1646/#1655 removed from the imports when converting teardowns to the retry-hardened rmrf helper (tests/tmp-rm.ts). Every other teardown in this file already uses rmrf; this one was missed. Without it, every PR merge-ref run fails here.
…PTY flake) Last holdout of the #1646/#1655 teardown-hardening sweep: cleanup() used bare fs.rmSync, so a dying race child's tsx transform-cache write could outlive the parent's delete and fail the whole suite with ENOTEMPTY on Windows even though the lease assertions passed. Aligns with the repo-wide maxRetries/retryDelay pattern. Found while triaging red CI on the #3701 WS byte-budget branch.
…PTY) tests/overlay-busy-lock.test.ts:27 was a bare-rmSync holdout from the ranxianglei#1655 sweep (family ranxianglei#1646/ranxianglei#1194/ranxianglei#1208/ranxianglei#2799/ranxianglei#2908). On the windows-22 CI shard its cleanup races tsx transform-cache writes left behind by the six racing children after SIGTERM and fails with ENOTEMPTY although every lease assertion passed (observed on PR ranxianglei#3706's CI run). Adopts the repo-standard { maxRetries: 10, retryDelay: 100 } pattern (tests/storage-replicas.test.ts:103 et al.). Pre-existing holdout, kept out of ranxianglei#3706's diff on purpose.
What
New shared test util
tests/tmp-rm.ts:Replaces all 354 bare
rmSync(dir, { recursive: true, force: true })teardown calls across 91 test files (count via exact paren-balanced parse of everyrmSync(call intests/— my issue reply said 339/87 from a coarser regex; the parsed number is authoritative). Orphaned namedrmSyncimports dropped in the 44 files where nothing else used them.Why
Bare recursive
rmSyncthrowsENOTEMPTYon loaded CI runners when a spawned child (proxy under test) recreates entries between rimraf's readdir and rmdir. Node's internal rimraf only retries transient errors (ENOTEMPTY,EACCES,EPERM,EMFILE,EBUSY) whenmaxRetriesis set; without it the firstENOTEMPTYpropagates straight into the test'sfinallyand turns a green suite red. Observed: CI run 36520549393,issue1086-chain-self-exemptionT3, ubuntu-latest Node 22 — all assertions passed, throw came from teardown line 317.The precedent for the fix already exists in-tree at
tests/issue1086-chain-self-exemption.test.ts:663(maxRetries: 10, retryDelay: 50); this PR just gives the rest of the tree the same hardening through one shared helper instead of 91 inline option sets.Worst-case added teardown latency per path is bounded (~2.75s, linear
retryDelay * attemptbackoff), only on runners that actually hit the race.Scope / behavior
fs.rmSync(path, { force: true })sites (17, e.g.store.test.ts:245,proxy-persist.test.ts:275,479) deliberately left alone: norecursivemeans no rmdir race.try/catchteardown sites keep their catch aroundrmrf.watchdog-health*.test.tsawaited the synchronousrmSync— converted, still sync, still harmless.Pre-flight
npm run typecheck: PASSnpm testfull suite: 3174 pass / 0 fail / 16 skipped (first local run had exactly one failure —issue1452-socket-hardeningstall-guard timing flake under parallel load, 12/12 green in isolation, zero logic diff in that file beyond import+teardown; second full run fully green)npm run build: PASStsconfig.jsonerror set compared against clean master baseline: identical modulo line numbers (904 pre-existing test-lane type errors, none new)Fixes #1646