Skip to content

Commit 019ba08

Browse files
authored
Fix flakiness in RequestsCanBeAbortedMidRead (#4881)
Addresses dotnet/aspnetcore-internal#1521
1 parent 68f0aff commit 019ba08

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Servers/Kestrel/test/FunctionalTests/RequestTests.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1206,7 +1206,12 @@ await connection.Send("POST / HTTP/1.1",
12061206
}
12071207
}
12081208

1209-
await Assert.ThrowsAsync<TaskCanceledException>(async () => await readTcs.Task);
1209+
var thrownEx = await Assert.ThrowsAnyAsync<Exception>(async () => await readTcs.Task);
1210+
1211+
// https://github.com/aspnet/AspNetCore-Internal/issues/1521
1212+
// In more recent versions of Kestrel, we expect this to always be a TaskCanceledException,
1213+
// but without the changes in https://github.com/aspnet/KestrelHttpServer/pull/2844, this is flaky.
1214+
Assert.True(thrownEx is TaskCanceledException || thrownEx is IOException, $"{thrownEx} is neither a TaskCanceledException nor IOException.");
12101215

12111216
// The cancellation token for only the last request should be triggered.
12121217
var abortedRequestId = await registrationTcs.Task;

0 commit comments

Comments
 (0)