Skip to content

Unobserved Task exception from k8s.LineSeparatedHttpContent.CancelableStream.ReadAsync after Upgrade #1661

@aukevin

Description

@aukevin

I'm working on a series of package upgrades from an old project.
In this case I'm trying to upgrade the KubernetesClient package from 3.0.7 to 17.0.4.
This was done mainly by using the CoreV1 versions of old methods, for example:

kubernetesClient.ListNamespacedPod(@namespace);

became

kubernetesClient.CoreV1.ListNamespacedPod(@namespace);

and

using (Watcher<V1Endpoints> watcher = await kubernetesClient.WatchNamespacedEndpointsAsync(
    this.endpointName,
    this.endpointNamespace,
    onEvent: this.OnEvent,
    onError: this.OnException,
    onClosed: this.OnClose))

became

using (Watcher<V1Endpoints> watcher = kubernetesClient.CoreV1
    .ListNamespacedEndpointsWithHttpMessagesAsync(this.endpointNamespace, fieldSelector: $"metadata.name={this.endpointName}", watch: true)
    .Watch<V1Endpoints, V1EndpointsList>(
        onEvent: this.OnEvent,
        onError: this.OnException,
        onClosed: this.OnClose))

Functionally, it seems to be working.

However, I'm seeing some new Unobserved Exception Errors that look something like this:

System.AggregateException: A Task's exception(s) were not observed either by Waiting on the Task or accessing its Exception property. As a result, the unobserved exception was rethrown by the finalizer thread. (The request was aborted.)
 ---> System.IO.IOException: The request was aborted.
   at System.Net.Http.Http2Connection.ThrowRequestAborted(Exception innerException)
   at System.Net.Http.Http2Connection.Http2Stream.CheckResponseBodyState()
   at System.Net.Http.Http2Connection.Http2Stream.TryReadFromBuffer(Span`1 buffer, Boolean partOfSyncRead)
   at System.Net.Http.Http2Connection.Http2Stream.ReadDataAsync(Memory`1 buffer, HttpResponseMessage responseMessage, CancellationToken cancellationToken)
   at k8s.LineSeparatedHttpContent.CancelableStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
   at System.IO.StreamReader.ReadBufferAsync(CancellationToken cancellationToken)
   at System.IO.StreamReader.ReadLineAsyncInternal(CancellationToken cancellationToken)
   --- End of inner exception stack trace ---

I'm at a bit of a loss for how to figure out what's causing the issue.
Has anyone seen something like this before?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions