From 7af69c5521849c081245625fca06b78dfe6d0ac6 Mon Sep 17 00:00:00 2001 From: "Ahmet Ibrahim Aksoy (from Dev Box)" Date: Fri, 18 Aug 2023 23:45:00 +0300 Subject: [PATCH 1/2] Add Task.Delay to give more time for reset frame --- .../tests/FunctionalTests/BidirectionStreamingTest.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/BidirectionStreamingTest.cs b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/BidirectionStreamingTest.cs index d18de54bc46cb..5d811a1406000 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/BidirectionStreamingTest.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/BidirectionStreamingTest.cs @@ -143,6 +143,8 @@ public async Task AfterReadResponseServerError_ClientWrite() // Server sends RST_STREAM. await connection.WriteFrameAsync(new RstStreamFrame(FrameFlags.EndStream, 0, streamId)); + await Task.Delay(15); + await Assert.ThrowsAsync(() => requestStream.WriteAsync(new byte[50]).AsTask()); } } From 1fff6e1640910ee9a73074c74c786c83bb909e75 Mon Sep 17 00:00:00 2001 From: "Ahmet Ibrahim Aksoy (from Dev Box)" Date: Sun, 20 Aug 2023 13:22:06 +0300 Subject: [PATCH 2/2] Apply James' solution --- .../FunctionalTests/BidirectionStreamingTest.cs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/BidirectionStreamingTest.cs b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/BidirectionStreamingTest.cs index 5d811a1406000..ce79f20ad4efe 100644 --- a/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/BidirectionStreamingTest.cs +++ b/src/libraries/System.Net.Http.WinHttpHandler/tests/FunctionalTests/BidirectionStreamingTest.cs @@ -143,9 +143,17 @@ public async Task AfterReadResponseServerError_ClientWrite() // Server sends RST_STREAM. await connection.WriteFrameAsync(new RstStreamFrame(FrameFlags.EndStream, 0, streamId)); - await Task.Delay(15); - - await Assert.ThrowsAsync(() => requestStream.WriteAsync(new byte[50]).AsTask()); + await Assert.ThrowsAsync(async () => + { + for (int i = 0; i < 10; i++) + { + await requestStream.WriteAsync(new byte[50]); + + // WriteAsync succeeded because handler hasn't processed RST_STREAM yet. + // Small wait before trying again. + await Task.Delay(50); + } + }); } }