-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Canceled client result can result in connection being closed #43054
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
In order to try to promote users to think about timeouts/cancellations when invoking methods on the client from the server, we want to force the user to pass in a interface ISingleClientProxy
{
- Task<T> InvokeCoreAsync<T>(string method, object?[] args, CancellationToken cancellationToken = default(CancellationToken));
+ Task<T> InvokeCoreAsync<T>(string method, object?[] args, CancellationToken cancellationToken);
}
static class ClientProxyExtensions
{
- static Task<T> InvokeAsync<T>(this ISingleClientProxy clientProxy, string method, CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+ static Task<T> InvokeAsync<T>(this ISingleClientProxy clientProxy, string method, CancellationToken cancellationToken);
- static Task<T> InvokeAsync<T>(this ISingleClientProxy clientProxy, string method, object? arg1, CancellationToken cancellationToken = default(CancellationToken));
+ static Task<T> InvokeAsync<T>(this ISingleClientProxy clientProxy, string method, object? arg1, CancellationToken cancellationToken);
// through 10 args
}
class HubLifetimeManager<THub>
{
- virtual Task<T> InvokeConnectionAsync<T>(string connectionId, string methodName, object?[] args, CancellationToken cancellationToken = default(CancellationToken));
+ virtual Task<T> InvokeConnectionAsync<T>(string connectionId, string methodName, object?[] args, CancellationToken cancellationToken);
}
class DefaultHubLifetimeManager<THub>
{
- Task<T> InvokeConnectionAsync<T>(string connectionId, string methodName, object?[] args, CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+ Task<T> InvokeConnectionAsync<T>(string connectionId, string methodName, object?[] args, CancellationToken cancellationToken);
}
class RedisHubLifetimeManager<THub>
{
- override Task<T> InvokeConnectionAsync<T>(string connectionId, string methodName, object?[] args, CancellationToken cancellationToken = default(System.Threading.CancellationToken));
+ override Task<T> InvokeConnectionAsync<T>(string connectionId, string methodName, object?[] args, CancellationToken cancellationToken);
} |
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
I think this API makes sense. APIs like In the case of these I think forcing people manually pass in a |
API Approved! |
Using the new client results feature in SignalR, if you pass in a cancellation token to
InvokeAsync
and cancel it, the server-side will properly clean-up the call, but the client-side will still send a result it produces one which will result in the HubProtocol serializer throwing when trying to resolve the type to deserialize the response to (as the server-side doesn't know about the invocation anymore). When the HubProtocol throws the connection is closed because we have to assume the connections pipe is no longer usable (partial reads etc.).aspnetcore/src/SignalR/server/Core/src/Internal/HubConnectionBinder.cs
Lines 24 to 30 in bf02bf2
The text was updated successfully, but these errors were encountered: