Skip to content

Disposing transports can hang when running in .NET framework #255

Description

@eiriktsarpalis

This is because the read loop in the core transport abstraction uses TextWriter:

if (await _serverOutput.ReadLineAsync(cancellationToken).ConfigureAwait(false) is not string line)

var line = await _inputReader.ReadLineAsync(shutdownToken).ConfigureAwait(false);

Which in netstandard2.0 is not cancellable and requires a polyfill that does not properly honor the cancellation token:

public static Task<string> ReadLineAsync(this TextReader reader, CancellationToken cancellationToken)
{
if (cancellationToken.IsCancellationRequested)
{
return Task.FromCanceled<string>(cancellationToken);
}
return reader.ReadLineAsync();
}

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