NotSupportedException: 'Cancellation of stream writes is not supported by this gRPC implementation.'
See original GitHub issueGrpc.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 WriteAsyncChallenge.zip.
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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.Thank you for your feedback. We’re closing this issue as the behavior discussed is by design.