Skip to content

Retry temp-dir deletes in test teardown to clear transient Windows locks - #375

Merged
TwitchBronBron merged 1 commit into
masterfrom
bugfix/temp-dir-teardown-retries
Jun 23, 2026
Merged

Retry temp-dir deletes in test teardown to clear transient Windows locks#375
TwitchBronBron merged 1 commit into
masterfrom
bugfix/temp-dir-teardown-retries

Conversation

@chrisdp

@chrisdp chrisdp commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Follow-up to #368. That PR added forceDeleteDir to diagnose the intermittent Windows CI failure where a test's teardown couldn't delete the shared .tmp dir (ENOTEMPTY: directory not empty, rmdir ...). The diagnostics confirmed the cause: an earlier test leaves a file handle open, so Windows keeps the directory entry around until that handle closes.

This makes forceDeleteDir recover from that instead of just reporting it:

  • Retries the delete with a linear backoff (10 attempts, 100ms base), giving any lingering handle time to close before the rmdir.
  • Async, awaiting util.sleep between attempts so pending handle-close callbacks can run during the wait; a synchronous wait would block the event loop and prevent the handle from closing. All call sites updated to await it.
  • Still logs the remaining paths plus the error message and stack, then re-throws, if every attempt fails.

forceDeleteDir now retries the delete with a linear backoff (and is async,
awaiting util.sleep between attempts) so a file handle an earlier test left
open has time to close before the rmdir, instead of failing the build with
ENOTEMPTY. It still logs the remaining paths and re-throws if every attempt
fails. All call sites updated to await it.
@TwitchBronBron
TwitchBronBron merged commit 33848c9 into master Jun 23, 2026
8 checks passed
@TwitchBronBron
TwitchBronBron deleted the bugfix/temp-dir-teardown-retries branch June 23, 2026 16:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants