From 47aed028d487626ea3be651cb3a88c30e20793f6 Mon Sep 17 00:00:00 2001 From: Aditya Mandaleeka Date: Tue, 17 Feb 2026 13:51:10 -0800 Subject: [PATCH] Fix race in RST_STREAM_IncompleteRequest tests Move tcs.TrySetResult() after WaitForConnectionErrorAsync to prevent the response HEADERS from racing with the GOAWAY frame. Same fix pattern as #57450 applied to AdditionalDataFrames and AdditionalTrailerFrames variants. --- .../InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs index 9ab5ceaa4d52..338879c67a92 100644 --- a/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs +++ b/src/Servers/Kestrel/test/InMemory.FunctionalTests/Http2/Http2ConnectionTests.cs @@ -3541,11 +3541,12 @@ public async Task RST_STREAM_IncompleteRequest_AdditionalDataFrames_ConnectionAb await SendDataAsync(1, new byte[2], endStream: false); await SendRstStreamAsync(1); await SendDataAsync(1, new byte[10], endStream: false); - tcs.TrySetResult(); await WaitForConnectionErrorAsync(ignoreNonGoAwayFrames: false, expectedLastStreamId: 1, Http2ErrorCode.STREAM_CLOSED, CoreStrings.FormatHttp2ErrorStreamAborted(Http2FrameType.DATA, 1)); + tcs.TrySetResult(); // Don't let the response start until after the abort + AssertConnectionEndReason(ConnectionEndReason.FrameAfterStreamClose); } @@ -3567,11 +3568,12 @@ public async Task RST_STREAM_IncompleteRequest_AdditionalTrailerFrames_Connectio await SendDataAsync(1, new byte[2], endStream: false); await SendRstStreamAsync(1); await SendHeadersAsync(1, Http2HeadersFrameFlags.END_HEADERS | Http2HeadersFrameFlags.END_STREAM, _requestTrailers); - tcs.TrySetResult(); await WaitForConnectionErrorAsync(ignoreNonGoAwayFrames: false, expectedLastStreamId: 1, Http2ErrorCode.STREAM_CLOSED, CoreStrings.FormatHttp2ErrorStreamAborted(Http2FrameType.HEADERS, 1)); + tcs.TrySetResult(); // Don't let the response start until after the abort + AssertConnectionEndReason(ConnectionEndReason.FrameAfterStreamClose); }