Skip to content

Fix Common.Interop.UnitTests.TestSend infinite hang on CI#47123

Merged
LegendaryBlair merged 1 commit intomicrosoft:mainfrom
yeelam-gordon:fix/interop-test-hang
Apr 21, 2026
Merged

Fix Common.Interop.UnitTests.TestSend infinite hang on CI#47123
LegendaryBlair merged 1 commit intomicrosoft:mainfrom
yeelam-gordon:fix/interop-test-hang

Conversation

@yeelam-gordon
Copy link
Copy Markdown
Contributor

Summary

Fixes an infinite hang in Common.Interop.UnitTests.TestSend that caused the x64 CI job to time out at 80 minutes on retried runs (originally observed on #47106, but the race is latent in any run that shares a CI agent with a previous run).

Root cause

The test used two machine-global named pipes (\.\pipe\serverside and \.\pipe\clientside) as fixed constants, and waited for the pipe callback with an unbounded
eset.WaitOne().

If a prior test run on the same CI agent left a pipe handle alive (e.g. after a job cancellation or a flaky cleanup), the next run's TwoWayPipeMessageIPCManaged handshake would silently never complete, and WaitOne() would block until the pipeline's job-level timeout (~80 minutes) killed the agent.

Fix

Two small, orthogonal changes in InteropTests.cs:

  1. Unique pipe names per run — suffix the pipe paths with Environment.ProcessId + a fresh Guid, so runs on the same agent can never collide.
  2. Bounded waitreset.WaitOne(TimeSpan.FromSeconds(30)) wrapped in Assert.IsTrue with a diagnostic message identifying the pipes. A broken handshake now fails the test in 30 s with a clear error, instead of hanging the CI job.

The inner Assert.AreEqual(testString, msg) — the actual correctness check — is unchanged. On the happy path the callback fires in milliseconds and the test behaves identically to before.

Verification

Built and ran locally with VS2026 MSBuild (x64 Release): TestSend passes in ~139 ms.

Follow-up (not in this PR)

TwoWayPipeMessageIPC.cpp still relies on a Thread.Sleep(100) race workaround (comment in the test) for server-ready timing. A proper handshake there would let us drop the sleep; out of scope here.

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

This PR fixes a CI hang in Common.Interop.UnitTests.TestSend by eliminating cross-run named pipe collisions and replacing an unbounded wait with a bounded timeout, so broken pipe handshakes fail quickly instead of timing out the job.

Changes:

  • Generate unique machine-global named pipe names per test run using Environment.ProcessId + Guid.
  • Replace reset.WaitOne() with Assert.IsTrue(reset.WaitOne(timeout)) and a diagnostic timeout message.

Comment thread src/common/interop/interop-tests/InteropTests.cs Fixed
The test used machine-global pipe names (\\.\pipe\serverside, \\.\pipe\clientside) and an unbounded reset.WaitOne(). On CI this combination could hang the x64 leg for the full 80-minute job timeout when two runs collided on the same agent or the pipe handshake raced.

- Suffix pipe names with Environment.ProcessId + Guid so every run gets a unique pair, eliminating cross-run collisions on shared agents.

- Bound WaitOne to 30s with an assertive failure message so a genuine handshake failure fails the test quickly with diagnostics instead of starving the CI job.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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

Copilot reviewed 1 out of 1 changed files in this pull request and generated no new comments.

@LegendaryBlair LegendaryBlair merged commit 8ad571d into microsoft:main Apr 21, 2026
15 checks passed
@yeelam-gordon yeelam-gordon deleted the fix/interop-test-hang branch April 21, 2026 03:25
@LegendaryBlair LegendaryBlair added 0.99 Area-Tests issues that relate to tests labels Apr 21, 2026
@LegendaryBlair LegendaryBlair added this to the PowerToys 0.99 milestone Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0.99 Area-Tests issues that relate to tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants