Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

NotSupportedException: 'Cancellation of stream writes is not supported by this gRPC implementation.'

See original GitHub issue

Grpc.Net 2.46.0, Grpc.Core 2.46.1

Is your feature request related to a problem? Please describe.

As an API user, i want to know if IAsyncStreamWriter supports WriteAsync(message, CancellationToken). I don’t want to guess or to catch NotSupportedException thrown by the default implementation.

Describe the solution you’d like

change the default implementation, remove NotSupportedException:

public interface IAsyncStreamWriter<T>
    Task WriteAsync(T message, CancellationToken cancellationToken) => WriteAsync(message);

Describe alternatives you’ve considered

add indicator whether the current AsyncStreamWriter supports WriteAsync(message, CancellationToken)

public interface IAsyncStreamWriter<T>
    bool CanCancelWriteAsync => false; // default false;

    Task WriteAsync(T message, CancellationToken cancellationToken)
        if (cancellationToken.CanBeCanceled && !CanCancelWriteAsync)
            throw new NotSupportedException("Cancellation of stream writes is not supported by this gRPC implementation.");

        return WriteAsync(message);

Additional context

Few examples of WriteAsync in context of Grpc.Net and Grpc.Core

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

Falco20019commented, Jun 20, 2022

This sadly also did bite us… ReSharper is creating warnings that there is a variant with cancellation token support. Our users just applied it (as it’s usually useful) and found out later that this is throwing an exception. So I’m also not too happy with the solution. In my opinion, the macro checking for #if NETSTANDARD2_1_OR_GREATER is misleading.

JamesNKcommented, May 31, 2022

Thank you for your feedback. We’re closing this issue as the behavior discussed is by design.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Grpc throws Specified method is not supported
I am unable to call that service from client if I add CallOptions to the service method parameters for passing bearer token. When...
Read more >
Announcing gRPC JSON transcoding for .NET - .NET Blog
JSON transcoding doesn't replace MVC or Minimal APIs. It only supports JSON, and it's very opinionated about how Protobuf maps to JSON.
Read more >
gRPC Stream Cancellation, under what conditions?
So once again my question is this: under what conditions would an HTTP/2 gRPC stream be cancelled? the error message above does not...
Read more >
Implementing Microservices with gRPC and .NET Core 3.1
NotSupportedException : HTTP/2 over TLS is not supported on macOS due to missing ALPN support. This is a known issue that affects macOS...
Read more >
GRPC Core: Status codes and their use in gRPC
Code Number Description OK 0 Not an error; returned on success. FAILED_PRECONDITION 9 OUT_OF_RANGE 11
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found