diff --git a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs index a9b1be6e7766a2..3036935ef5533d 100644 --- a/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs +++ b/src/libraries/System.Net.Http/tests/FunctionalTests/HttpClientHandlerTest.Http2.cs @@ -139,7 +139,8 @@ public async Task Http2_StreamResetByServerBeforePrefix_RequestFailsWithGoawayPr Http2LoopbackConnection connection = await server.AcceptConnectionAsync(timeout: null); _ = await connection.ReadSettingsAsync(); - + // Wait until client starts sending request + _ = await connection.ReadFrameAsync(TestHelper.PassingTestTimeout); GoAwayFrame goAwayFrame = new GoAwayFrame(lastStreamId: 0, (int)ProtocolErrors.HTTP_1_1_REQUIRED, additionalDebugData: Array.Empty(), streamId: 0); await connection.WriteFrameAsync(goAwayFrame); @@ -363,6 +364,8 @@ public async Task Http2_IncorrectServerPreface_RequestFailsWithAppropriateHttpPr Http2LoopbackConnection connection = await server.AcceptConnectionAsync(); await connection.ReadSettingsAsync(); + // Wait until client starts sending request + _ = await connection.ReadFrameAsync(TestHelper.PassingTestTimeout); await connection.SendGoAway(0, ProtocolErrors.INTERNAL_ERROR); await AssertProtocolErrorAsync(sendTask, ProtocolErrors.INTERNAL_ERROR);