test(workspaces): avoid module-list races when finding fixture processes #50596

Open
LegendaryBlair opened 1:52am on September 16, 2026 wants to merge 126 Ξ” into microsoft/powertoys main from
LegendaryBlair/fix-workspaces-process-image-query

Pull Request Overview

  • Opened on September 16, 2026
  • Status Open
  • Commit count 1 with first commit September 16, 2026

Total Delta

126 Total Diff Delta

Open Days

Open 3 weekdays

Test Delta

126 Diff Delta in Test Files
Breakdown by Phase

How long has this pull request spent in each phase of its lifecycle?

Fraction of total time Business days Phase
 
0.0 days Authoring 1 commit before pull request opened for review
 
0.0 days Awaiting first review
 
2.3 days Revising work with 0 commits in response to 1 review that left 2 comments

Total time for pull request still awaiting merge: 2.3 business days

Author avatar

test(workspaces): avoid module-list races when finding fixture processes

Summary of the Pull Request

Avoid an intermittent ERROR_PARTIAL_COPY failure when Workspaces UI tests identify a newly created fixture process.

Replace the helper's Process.MainModule.FileName read with QueryFullProcessImageName, using limited-query access. A live process can exist before its loader has initialized the module list; its executable image can already be queried without enumerating modules.

This is a minimal test-only change: one caller replacement, a native image-query helper, and one controlled startup regression. No product, IPC, installer, or pipeline behavior changes are included.

PR Checklist


  • [x] Communication: The focused test-stability fix was requested during the Workspaces CI investigation.

  • [x] Tests: Added a suspended-process regression; it fails with the original helper and passes with the image query.

N/A: localization, new binaries/dependencies, settings migrations, and user documentation changes.

Detailed Description of the Pull Request / Additional comments



  • src/modules/Workspaces/Tests/Workspaces.UITests.Next/TestAppFixture.cs keeps its process-name filtering, full-path identity comparison, exit handling, and window-readiness assertions. Only the path lookup changes.


  • src/modules/Workspaces/Tests/Workspaces.UITests.Next/NativeMethods.cs opens a limited-query process handle, reads the Win32 executable path, disposes the handle, and propagates unexpected failures.


  • src/modules/Workspaces/Tests/Workspaces.UITests.Next/ProcessImagePathTests.cs starts the existing test fixture suspended, queries its path before module initialization, and terminates only that owned process without resuming it or opening a window.

The existing exception filter only tolerates a process that has exited. It does not handle a live process whose module list is still initializing. This was observed in CI 388931 at TestAppFixture.ProcessIds() and reproduced independently.

No blanket exception suppression, fixed sleep, longer timeout, or weaker ownership assertion is introduced. This addresses process-image observation, not unrelated window-positioning failures.

Validation Steps Performed


  • Built the actual x64 Release UI-test project with the repository build script.

  • Ran the new non-UI regression against the old helper: failed with Win32 error 299 from process-module enumeration.

  • Ran the same regression with the fix: 1 passed, 0 failed, 0 skipped. The child stayed suspended and was cleaned up through its retained handles.

  • No new warnings remain in the image-query helper or regression.

  • A local Windows 10 VM is unavailable, as confirmed by the contributor. No local full-UI or VM-matrix pass is claimed.


  • CI 388945 fully succeeded. The same UI-test project, including the new startup regression, passed 34/34 on Windows 10, 34/34 on Windows 11, and 34/34 on ARM64, with no skipped cases.

Comments Threads Pending Resolution

ljharb reviewed on September 16, 2026
ljharb left a comment

### 🟒 Approval recommended

The focused test-only change correctly addresses the module-list race and includes targeted regression coverage.

Pull request overview

Prevents intermittent Workspaces UI-test process discovery failures before module initialization.

**Changes:**
- Queries executable paths using limited process access.
- Updates fixture process matching.
- Adds a suspended-process regression test.

File summaries

| File | Description |
| ---- | ----------- |
| `TestAppFixture.cs` | Uses the race-safe path query. |
| `NativeMethods.cs` | Adds process image-path interop. |
| `ProcessImagePathTests.cs` | Verifies querying a suspended process. |

Review details

- **Files reviewed:** 3/3 changed files
- **Comments generated:** 0
- **Review effort level:** Balanced

---

πŸ’‘ Add a `code-review` agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Resolved Comment Threads

No resolved comments have been left on this PR.