Skip to content

test(provision): retry scratch-dir removal after a killed child on Windows - #324

Closed
Brooooooklyn wants to merge 1 commit into
mainfrom
fix/provision-group-close-rm-retry
Closed

Brooooooklyn wants to merge 1 commit into
mainfrom
fix/provision-group-close-rm-retry

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Sep 16, 2026 •

Copy link
Copy Markdown
Member

What

test (windows-latest, unit) on main 2bae6708 failed in provision-runner-signals.test.ts → "normal close confirms the whole GROUP" (run 35048960102). The assertions passed; afterEach then threw:

Error: EPERM, Permission denied: \\?\D:\a\void\void\packages\void\test\unit\.tmp-group-close
  ❯ packages/void/test/unit/provision.cases.ts:5702:5

Why

The scratch directory is the cwd of the spawned leader and grandchild. On Windows TerminateProcess returns before the dead process releases its handles, so an immediate rmSync races that release.

Fix

removeProcessScratchDir(dir) = rmSync(dir, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 }). Node retries EPERM/EBUSY/ENOTEMPTY with linear backoff when maxRetries is set. Used in beforeEach/afterEach of the three describes that spawn a real wrangler stand-in inside a scratch cwd (.tmp-timeout-kill, .tmp-signal-teardown, .tmp-group-close). Test bodies are unchanged.

Local (macOS): vp fmt --check / vp lint / typecheck 0, provision-runner-signals.test.ts 14/14. The Windows proof is this PR's CI.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SStP281NuirMSouULEE2pW


Note

Low Risk
Test-only teardown change with no production or runtime behavior impact.

Overview
Fixes flaky Windows unit teardown in provision runner tests where afterEach could fail with EPERM while deleting scratch dirs used as spawned process cwd.

Adds removeProcessScratchDir, which deletes via rmSync with maxRetries: 10 and retryDelay: 100 so Node retries EPERM/EBUSY/ENOTEMPTY until handles are released after TerminateProcess. beforeEach/afterEach in the three describes that spawn real wrangler stand-ins (hard timeout kill, parent-signal teardown, group-close) now use this helper instead of immediate recursive rmSync; test assertions are unchanged.

Reviewed by Cursor Bugbot for commit e06f1de. Bugbot is set up for automated code reviews on this repo. Configure here.

…ndows

`test (windows-latest, unit)` on main `2bae6708` failed in
`provision-runner-signals.test.ts` — "normal close confirms the whole
GROUP": the assertions passed, then `afterEach` `rmSync('.tmp-group-close')`
threw `EPERM`. The directory is the cwd of the spawned leader and
grandchild. On Windows `TerminateProcess` returns before the dead process
releases its handles, so an immediate `rmSync` races that release.

`removeProcessScratchDir` passes `maxRetries: 10, retryDelay: 100`, which
makes Node retry `EPERM`/`EBUSY`/`ENOTEMPTY` with linear backoff. The
three describes that spawn a real wrangler stand-in inside a scratch cwd
(`.tmp-timeout-kill`, `.tmp-signal-teardown`, `.tmp-group-close`) use it
in both `beforeEach` and `afterEach`. Test bodies are unchanged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SStP281NuirMSouULEE2pW
@cursor

cursor Bot commented Sep 16, 2026

Copy link
Copy Markdown

Bugbot couldn't run - usage limit reached

Bugbot is counted against Cursor usage for this user or team, and this run hit a usage or spend limit.

A user or team admin can review and increase usage limits in the Cursor dashboard.

(requestId: serverGenReqId_474b136f-607b-4a50-a029-8c2d7aeccf1a)

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 16, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-16T03:01:23.502037Z e06f1de PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@cpojer
cpojer deleted the fix/provision-group-close-rm-retry branch October 3, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant