Skip to content

.ConfigureAwait(false) in SignalR client libraries #39728

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

Merged
merged 4 commits into from
Jan 25, 2022
Merged

Conversation

halter73
Copy link
Member

.ConfigureAwait(false) in SignalR client libraries

  • Enable CA2007 (Consider calling ConfigureAwait on the awaited task) for SignalR client libraries and shared libraries
  • Don't use ForceAsync() in ignalR client libraries and shared libraries
    • The previous use of ForceAsync() could still cause deadlocks of the code using the client tried to block a UI thread (or any one-at-a-time SynchronizationContext) because internal SignalR logic would try to post back to it.

Fixes #39626
Partially addresses #31132

Copy link
Contributor

@pranavkm pranavkm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍🏽 We should also consider enabling this for things that aren't exclusively ASP.NET Core (e.g. DataProtection, Extensions.Features, JSInterop etc).

@@ -2090,6 +2091,90 @@ await using (var server = await StartServer<Startup>(ExpectedErrors))
}
}

[Theory]
[MemberData(nameof(TransportTypes))]
public async Task CanBlockOnAsyncOperationsWithOneAtATimeSynchronizationContext(HttpTransportType transportType)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we had tests like this before, but looks like they never got merged 😮
aspnet/SignalR#792

@davidfowl
Copy link
Member

Why are we using ConfigureAwait on the server side?

@Pilchie Pilchie added the area-signalr Includes: SignalR clients and servers label Jan 24, 2022
@halter73
Copy link
Member Author

Why are we using ConfigureAwait on the server side?

Fixed.

@halter73 halter73 merged commit 98bb246 into main Jan 25, 2022
@halter73 halter73 deleted the halter73/39626 branch January 25, 2022 20:54
@ghost ghost added this to the 7.0-preview1 milestone Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-signalr Includes: SignalR clients and servers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

SignalR C# Client StartAsync() CancellationToken not respected
5 participants