From 5cedff3daf135c84706aef5b5ab891453d33ebac Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Mon, 9 Mar 2026 16:51:29 -0500 Subject: [PATCH 1/2] Fix race in RST_STREAM_IncompleteRequest_AdditionalResetFrame test Move tcs.TrySetResult() after StopConnectionAsync so the response handler stays blocked until the connection has stopped. This prevents response HEADERS from being written before the GOAWAY frame, which caused the test to intermittently fail with 'Expected: GOAWAY, Actual: HEADERS'. This is the same fix pattern applied in #65454 for the sibling AdditionalDataFrames and AdditionalTrailerFrames tests, and in #57450 for the AdditionalWindowUpdateFrame test. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs index 9ab5ceaa4d52..2eb776f7fe59 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs @@ -3592,10 +3592,11 @@ public async Task RST_STREAM_IncompleteRequest_AdditionalResetFrame_IgnoreAdditi await SendDataAsync(1, new byte[1], endStream: false); await SendRstStreamAsync(1); await SendRstStreamAsync(1); - tcs.TrySetResult(); await StopConnectionAsync(expectedLastStreamId: 1, ignoreNonGoAwayFrames: false); + tcs.TrySetResult(); // Don't let the response start until after the connection stops + AssertConnectionNoError(); } From 851221c9f987e6bd4f9d3da7d47c3057bea08ef4 Mon Sep 17 00:00:00 2001 From: Larry Ewing Date: Mon, 9 Mar 2026 22:16:16 -0500 Subject: [PATCH 2/2] Fix RST_STREAM additional reset test ordering Wait for the request to be aborted before releasing the application delegate gate in RST_STREAM_IncompleteRequest_AdditionalResetFrame_IgnoreAdditionalReset. This preserves the test intent while avoiding both the HEADERS-vs-GOAWAY race and the shutdown timeout.\n\nCo-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../Http2/Http2ConnectionTests.cs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs index 2eb776f7fe59..7496cf4b907a 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs @@ -3578,6 +3578,7 @@ await WaitForConnectionErrorAsync(ignoreNonGoAway [Fact] public async Task RST_STREAM_IncompleteRequest_AdditionalResetFrame_IgnoreAdditionalReset() { + var abortedTcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var tcs = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var headers = new[] @@ -3586,16 +3587,22 @@ public async Task RST_STREAM_IncompleteRequest_AdditionalResetFrame_IgnoreAdditi new KeyValuePair(InternalHeaderNames.Path, "/"), new KeyValuePair(InternalHeaderNames.Scheme, "http"), }; - await InitializeConnectionAsync(context => tcs.Task); + await InitializeConnectionAsync(context => + { + context.RequestAborted.Register(() => abortedTcs.TrySetResult()); + return tcs.Task; + }); await StartStreamAsync(1, headers, endStream: false); await SendDataAsync(1, new byte[1], endStream: false); await SendRstStreamAsync(1); await SendRstStreamAsync(1); - await StopConnectionAsync(expectedLastStreamId: 1, ignoreNonGoAwayFrames: false); + await abortedTcs.Task; + + tcs.TrySetResult(); // Don't let the response start until after the request aborts - tcs.TrySetResult(); // Don't let the response start until after the connection stops + await StopConnectionAsync(expectedLastStreamId: 1, ignoreNonGoAwayFrames: false); AssertConnectionNoError(); }