Skip to content

[HTTP/3] NullReferenceException on cancellation #48624

Closed
@JamesNK

Description

@JamesNK

There is a gRPC functional test called ServerStreaming_CancellationOnClientWhileMoveNext_CancellationSentToServer.

The test:

  1. Starts a HTTP/3 request
  2. Reads from the request body
  3. Disposes HttpResponseMessage (which cancels the request)
  4. Reads from the request body

Instead of throwing the same exception as HTTP/2 (I think is an OCE), a NullReferenceException is thrown.

Stack trace:

    System.NullReferenceException: Object reference not set to an instance of an object.
       at System.Net.Http.Http3RequestStream.HandleReadResponseContentException(Exception ex, CancellationToken cancellationToken)
       at System.Net.Http.Http3RequestStream.ReadResponseContentAsync(HttpResponseMessage response, Memory`1 buffer, CancellationToken cancellationToken)
       at Grpc.Net.Client.StreamExtensions.ReadMessageAsync[TResponse](Stream responseStream, GrpcCall call, Func`2 deserializer, String grpcEncoding, Boolean singleMessage, CancellationToken cancellationToken) in C:\Development\Source\grpc-dotnet\src\Grpc.Net.Client\Internal\StreamExtensions.cs:line 78
       at Grpc.Net.Client.Internal.HttpContentClientStreamReader`2.MoveNextCore(CancellationToken cancellationToken) in C:\Development\Source\grpc-dotnet\src\Grpc.Net.Client\Internal\HttpContentClientStreamReader.cs:line 161

I think the problem is a null _connection is called here:

case Http3ConnectionException _:
// A connection-level protocol error has occurred on our stream.
_connection.Abort(ex);
throw new IOException(SR.net_http_client_execution_error, new HttpRequestException(SR.net_http_client_execution_error, ex));

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions