Skip to content

Harden Copilot Electron test temp-dir cleanup on Windows#314901

Merged
dmitrivMS merged 4 commits into
mainfrom
copilot/fix-electron-tests-ebusy
May 7, 2026
Merged

Harden Copilot Electron test temp-dir cleanup on Windows#314901
dmitrivMS merged 4 commits into
mainfrom
copilot/fix-electron-tests-ebusy

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented May 7, 2026

Fixes #314897

Description

Electron tests were intermittently failing after the extension host crashed because Windows still held Crashpad dump files open during temp-dir teardown, surfacing as EBUSY from fs.rm. This updates the Copilot Electron test runner cleanup path to tolerate transient file locks instead of failing the run during best-effort cleanup.

  • Problem

    • Cleanup in runTest.ts removed the test user-data dir once, without retries.
    • On Windows, post-crash Crashpad artifacts can still be locked briefly, so teardown could fail even after the real test failure had already been handled.
  • Changes

    • Added retry-enabled temp-dir cleanup directly in runTest.ts.
    • Switched cleanup to fs.rm(..., { recursive: true, force: true, maxRetries, retryDelay }) so transient EBUSY/EPERM locks are retried by Node.
    • Applied the same cleanup path to both temporary directories created by the runner:
      • --user-data-dir
      • temporary workspace folder
    • Made cleanup failures non-fatal after logging, so teardown does not mask the actual test outcome.
  • Example

    await fs.rm(dir, {
    	recursive: true,
    	force: true,
    	maxRetries: 10,
    	retryDelay: 200
    });

Testing

  • cd extensions/copilot && npm run typecheck
  • node --experimental-strip-types build/hygiene.ts extensions/copilot/src/extension/completions-core/vscode-node/extension/test/runTest.ts
  • Secret scan passed for the updated file

Copilot AI requested review from Copilot and removed request for Copilot May 7, 2026 02:34
Copilot AI linked an issue May 7, 2026 that may be closed by this pull request
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/4fc94938-ddf6-47c3-9ad8-342f7156a10f

Co-authored-by: dmitrivMS <9581278+dmitrivMS@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 7, 2026 02:40
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/4fc94938-ddf6-47c3-9ad8-342f7156a10f

Co-authored-by: dmitrivMS <9581278+dmitrivMS@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 7, 2026 02:40
Copilot AI changed the title [WIP] Fix build failure: Electron tests fail with EBUSY Harden Copilot Electron test temp-dir cleanup on Windows May 7, 2026
Copilot AI requested a review from dmitrivMS May 7, 2026 02:41
Copy link
Copy Markdown
Contributor

@dmitrivMS dmitrivMS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot See and fix comments

Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/6b8300d2-f7ec-495d-81d5-03363352274a

Co-authored-by: dmitrivMS <9581278+dmitrivMS@users.noreply.github.com>
Copilot AI requested review from Copilot and removed request for Copilot May 7, 2026 02:55
Copy link
Copy Markdown
Contributor Author

Copilot AI commented May 7, 2026

@copilot See and fix comments

Addressed the review comments in 7dc10e0.

Copilot AI requested a review from dmitrivMS May 7, 2026 02:56
@dmitrivMS dmitrivMS marked this pull request as ready for review May 7, 2026 02:56
Copilot AI review requested due to automatic review settings May 7, 2026 02:56
@dmitrivMS dmitrivMS enabled auto-merge (squash) May 7, 2026 02:56
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Hardens the Copilot Electron test runner teardown path so transient Windows file locks (e.g., Crashpad artifacts after an extension host crash) don’t cause the overall test run to fail during best-effort cleanup.

Changes:

  • Added a cleanupTestDirectory helper that deletes directories using fs.rm with force plus retry options (maxRetries, retryDelay) and logs failures without throwing.
  • Applied the improved cleanup to both the temporary --user-data-dir and the temporary workspace folder in the runner’s finally block.
Show a summary per file
File Description
extensions/copilot/src/extension/completions-core/vscode-node/extension/test/runTest.ts Makes temp-dir cleanup resilient to transient Windows locks by adding retry-enabled, non-fatal teardown for both created temp directories.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@microsoft microsoft deleted a comment from github-actions Bot May 7, 2026
@dmitrivMS dmitrivMS merged commit 05ffc3d into main May 7, 2026
30 checks passed
@dmitrivMS dmitrivMS deleted the copilot/fix-electron-tests-ebusy branch May 7, 2026 03:53
@vs-code-engineering vs-code-engineering Bot added this to the 1.120.0 milestone May 7, 2026
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.

Build failed: Electron Tests fail with EBUSY

4 participants