test(grpc-data): H2 review 10 - real Kestrel HTTP/2 proves the connection-close hook clears the session

In-process loopback h2c host: IConnectionLifetimeFeature.ConnectionClosed is exposed on the HTTP/2 stream context,
two requests on one connection share one session, and disposing the client connection clears it.
This commit is contained in:
Joseph Doherty
2026-11-23 22:12:28 -05:00
parent 7e22601ee7
commit 9a808ba218
2 changed files with 58 additions and 2 deletions
@@ -211,9 +211,11 @@ public sealed class DataConnectionGrpcService(IDataConnectionFactory factory, IO
/// The transport channel of this call: its HTTP/2 connection. Origin continuations are partitioned by it and cleared
/// when Kestrel reports the connection closed (idle expiry is the backstop where the feature is absent).
/// </summary>
private static DataHistoryChannel Channel(ServerCallContext context)
private static DataHistoryChannel Channel(ServerCallContext context) => ChannelOf(context.GetHttpContext());
/// <summary>The history channel of an HTTP request: its connection id, closed when Kestrel closes the connection.</summary>
internal static DataHistoryChannel ChannelOf(Microsoft.AspNetCore.Http.HttpContext http)
{
var http = context.GetHttpContext();
var closed = http.Features.Get<Microsoft.AspNetCore.Connections.Features.IConnectionLifetimeFeature>()?.ConnectionClosed
?? CancellationToken.None;
return new DataHistoryChannel("http:" + (http.Connection.Id ?? "unknown"), closed);