You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
test: canonical retrying removeTree helper; ban bare rm(recursive) in test teardown (ENOTEMPTY flakes) #805
Integration shards intermittently fail during test teardown with ENOTEMPTY: directory not empty, rmdir ... when rm(dir, { recursive: true, force: true }) races a late write (dev server, watcher, or child process) into the tree being removed. Passes on rerun.
#802 added maxRetries: 3, retryDelay: 50 to one site (packages/workbench/tests/support/example-acceptance.ts), and ten *-dev-server.test.ts files already carry maxRetries: 5, retryDelay: 50 by hand. There is no canonical helper: rg "rm\(.*recursive: true" finds ~1,200 bare sites across ~200 test files under packages/*/tests, so the next flake gets the next one-line patch.
Proposed mechanism (encode the lesson in structure)
Add one canonical removeTree(path) in packages/agent-bundle/tests/support/ (and re-export for workbench tests) that calls fs.rm(path, { force: true, recursive: true, maxRetries: 5, retryDelay: 50 }).
Migrate the existing maxRetries call sites and the teardown paths that spawn servers/watchers to it.
Ban the bare form in tests with a lint rule or a scripts/check-*.mjs grep gate (rm( + recursive: true without maxRetries under **/tests/**), so the pattern cannot regrow. Tests-only, so no changeset.
Filed instead of fixing inline because the migration is ~200 files and needs its own PR.
Test shape (behavior, not implementation)
Test the helper with an injected fs whose rm rejects with ENOTEMPTY once and then removes the directory; assert the directory is gone afterwards (existsSync false / stat rejects with ENOENT) and that a persistent ENOTEMPTY surfaces as the literal error after maxRetries. Do not assert that rm was called or how many times.
Activity