Skip to content

Commit 02432bf

Browse files
JamesNKcaptainsafia
authored andcommitted
Fix flaky ServerShutsDownGracefullyWhenMaxRequestBufferSizeExceeded (#58735)
1 parent e601dc5 commit 02432bf

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -280,22 +280,26 @@ public async Task ServerShutsDownGracefullyWhenMaxRequestBufferSizeExceeded()
280280

281281
// Dispose host prior to closing connection to verify the server doesn't throw during shutdown
282282
// if a connection no longer has alloc and read callbacks configured.
283-
try
284-
{
285-
await host.StopAsync();
286-
}
287-
// Remove when https://github.com/dotnet/runtime/issues/40290 is fixed
288-
catch (OperationCanceledException)
289-
{
290-
291-
}
283+
await host.StopAsync();
292284
host.Dispose();
293285
}
294286
}
295287
// Allow appfunc to unblock
296288
startReadingRequestBody.SetResult();
297289
clientFinishedSendingRequestBody.SetResult();
298-
await memoryPoolFactory.WhenAllBlocksReturned(TestConstants.DefaultTimeout);
290+
291+
try
292+
{
293+
await memoryPoolFactory.WhenAllBlocksReturned(TestConstants.DefaultTimeout);
294+
}
295+
catch (AggregateException)
296+
{
297+
// This test is inherently racey. The server could try to use blocks that have been disposed.
298+
// Ignore errors related to this:
299+
//
300+
// System.AggregateException : Exceptions occurred while accessing blocks(Block is backed by disposed slab)
301+
// ---- System.InvalidOperationException : Block is backed by disposed slab
302+
}
299303
}
300304

301305
private async Task<IHost> StartHost(long? maxRequestBufferSize,

0 commit comments

Comments
 (0)