From 52570bff8a7d1a68215a0a5c6d796b3d007b9987 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 24 Jun 2026 21:14:33 +0000 Subject: [PATCH 1/3] Initial plan From 86b1d9fa065a7ee187d4f85b30add8a2775ac6e9 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 24 Jun 2026 22:11:04 +0000 Subject: [PATCH 2/3] Fix flaky SendAsync_Success_ConnectionSetupActivityGraphRecorded test with TaskCompletionSource sync Co-authored-by: lewing <24063+lewing@users.noreply.github.com> --- .../tests/FunctionalTests/DiagnosticsTests.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs index f6a843cf21f530..fb22712deb360e 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs @@ -608,6 +608,10 @@ static async Task RunTest(string useVersion, string testAsync, string useTlsStri VerifyParent = false }; + // Synchronize client and server: server waits for client to finish req1 assertions before reading req2. + // This prevents a race where the server tries to read req2 before the client sends it. + TaskCompletionSource req1AssertionsDone = new(TaskCreationOptions.RunContinuationsAsynchronously); + await GetFactoryForVersion(useVersion).CreateClientAndServerAsync( async uri => { @@ -694,6 +698,9 @@ await GetFactoryForVersion(useVersion).CreateClientAndServerAsync( ActivityAssert.HasTag(conn, "server.port", uri.Port); ActivityAssert.HasTag(conn, "url.scheme", useTls ? "https" : "http"); + // Signal the server to read the second request now that all req1 assertions have passed. + req1AssertionsDone.SetResult(); + // The second request should reuse the first connection, connection_setup and wait_for_connection should not be recorded again. await client.SendAsync(CreateRequest(HttpMethod.Get, uri, Version.Parse(useVersion), exactVersion: true)); requestRecorder.VerifyActivityRecorded(2); @@ -713,6 +720,11 @@ await server.AcceptConnectionAsync(async connection => await connection.SendResponseAsync(HttpStatusCode.OK); connection.CompleteRequestProcessing(); + // Wait for the client to finish asserting the first request before reading the second. + // This prevents a race where a client assertion failure closes the connection before + // the second request is sent, causing a spurious server-side EOF exception. + await req1AssertionsDone.Task; + await connection.ReadRequestDataAsync(); await connection.SendResponseAsync(HttpStatusCode.OK); }); From ac0de6bfb750969fecd1a9b2e960510051e7d0cc Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 24 Jun 2026 22:20:22 +0000 Subject: [PATCH 3/3] Revert test change: DiagnosticsTests.cs restored to original state Co-authored-by: lewing <24063+lewing@users.noreply.github.com> --- .../tests/FunctionalTests/DiagnosticsTests.cs | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs index fb22712deb360e..f6a843cf21f530 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/DiagnosticsTests.cs @@ -608,10 +608,6 @@ static async Task RunTest(string useVersion, string testAsync, string useTlsStri VerifyParent = false }; - // Synchronize client and server: server waits for client to finish req1 assertions before reading req2. - // This prevents a race where the server tries to read req2 before the client sends it. - TaskCompletionSource req1AssertionsDone = new(TaskCreationOptions.RunContinuationsAsynchronously); - await GetFactoryForVersion(useVersion).CreateClientAndServerAsync( async uri => { @@ -698,9 +694,6 @@ await GetFactoryForVersion(useVersion).CreateClientAndServerAsync( ActivityAssert.HasTag(conn, "server.port", uri.Port); ActivityAssert.HasTag(conn, "url.scheme", useTls ? "https" : "http"); - // Signal the server to read the second request now that all req1 assertions have passed. - req1AssertionsDone.SetResult(); - // The second request should reuse the first connection, connection_setup and wait_for_connection should not be recorded again. await client.SendAsync(CreateRequest(HttpMethod.Get, uri, Version.Parse(useVersion), exactVersion: true)); requestRecorder.VerifyActivityRecorded(2); @@ -720,11 +713,6 @@ await server.AcceptConnectionAsync(async connection => await connection.SendResponseAsync(HttpStatusCode.OK); connection.CompleteRequestProcessing(); - // Wait for the client to finish asserting the first request before reading the second. - // This prevents a race where a client assertion failure closes the connection before - // the second request is sent, causing a spurious server-side EOF exception. - await req1AssertionsDone.Task; - await connection.ReadRequestDataAsync(); await connection.SendResponseAsync(HttpStatusCode.OK); });