Skip to content

Fix test flakiness#7400

Open
Evangelink wants to merge 2 commits intomainfrom
dev/amauryleve/json-rcp-flaky
Open

Fix test flakiness#7400
Evangelink wants to merge 2 commits intomainfrom
dev/amauryleve/json-rcp-flaky

Conversation

@Evangelink
Copy link
Member

Fix #7398

Copy link
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

Addresses flakiness in the server-mode TCP startup/abort path (Issue #7398) by tightening cancellation handling around TCP connection establishment and by broadening the set of cancellation-adjacent exceptions treated as expected during shutdown/abort.

Changes:

  • Adds a post-ConnectAsync cancellation check before calling TcpClient.GetStream() to avoid a race where the socket is closed by cancellation.
  • Consolidates multiple cancellation-related catch blocks in ServerTestHost into a single filtered catch that also covers InvalidOperationException from GetStream().

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/Platform/Microsoft.Testing.Platform/ServerMode/JsonRpc/MessageHandlerFactory.cs Adds a cancellation guard between successful connect and GetStream() to prevent “non-connected sockets” failures.
src/Platform/Microsoft.Testing.Platform/Hosts/ServerTestHost.cs Expands/centralizes cancellation exception handling to treat additional timing-dependent socket exceptions as expected during abort.

@Evangelink Evangelink enabled auto-merge February 14, 2026 15:03
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.

Investigate ServerCanBeStartedAndAborted_TcpIp test flakiness

1 participant