-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Require CancellationToken for client results (and fix cancel closing connection) #43249
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
Conversation
src/SignalR/server/StackExchangeRedis/src/RedisHubLifetimeManager.cs
Outdated
Show resolved
Hide resolved
src/SignalR/server/StackExchangeRedis/src/RedisHubLifetimeManager.cs
Outdated
Show resolved
Hide resolved
src/SignalR/common/Protocols.Json/src/Protocol/JsonHubProtocol.cs
Outdated
Show resolved
Hide resolved
Changed to remove the default timeout and require passing in a Edit: This would need to go through a quick API review if we agree on the approach. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it makes sense to try to force people to think about cancellation. Making them explicitly pass in CancellationToken.None
/default
seems like a reasonable way to do this. And we could add a default later if we really wanted to, right?
Anyway, let's update #43054 with the API proposal so more people can discuss.
With the current API I don't think so. |
We could add an option to set a default, but our default would need to be infinite 😄 |
@dotnet/aspnet-admins could I get a merge please? Code check is failing due to approved unshipped file changes. |
@adityamandaleeka is this approved for RC1❔ |
src/SignalR/common/Protocols.NewtonsoftJson/src/Protocol/NewtonsoftJsonHubProtocol.cs
Outdated
Show resolved
Hide resolved
Approved, this prevents a potentially bad disconnect issue in new 7.0 work. |
src/SignalR/common/Protocols.NewtonsoftJson/src/Protocol/NewtonsoftJsonHubProtocol.cs
Outdated
Show resolved
Hide resolved
…nsoftJsonHubProtocol.cs
Will complain the auto-squish didn't work and that'll hopefully remind me to merge this 😄 |
Ok, now it's ready. |
You could have done the JIT thing @adityamandaleeka but pinging me was fine, especially because my thought that auto-squish would complain when a build failed didn't pan out😀 |
That's a big hammer and I want to be sparing in my use of it 😄 |
…connection) (dotnet#43249) * WIP default cancel timeout for invokes * change * remove default token and default timeout * fix build * Update src/SignalR/common/Protocols.NewtonsoftJson/src/Protocol/NewtonsoftJsonHubProtocol.cs
Fixes #43054
For other types like StreamItem and Invocations we create
StreamBindingFailureMessage
andInvocationBindingFailureMessage
respectively in the hub protocols when a failure occurs. We might want to do something similar here, but since it's late in RC1 I think we should opt for not adding a new public class and instead ignore the result value of completion messages in this scenario.Additionally, this change adds a default timeout of 30 seconds to client result calls. This is done at theHubLifetimeManager
layer because we aren't able to control all call sites ofproxy.InvokeAsync
. This is also an option that could potentially result in new API (DefaultClientResultTimeout
or something). But again, late in RC1 that might be hard to swing. Users can pass in their ownCancellationToken
if they want to customize how long they will wait for a result, and this will override the 30 second default.Went with requiring user to pass in a
CancellationToken
to suggest that they think about cancellation when using the feature.