diff --git a/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs b/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs index 98524d6d9a..a36b69f842 100644 --- a/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs +++ b/src/SignalR/clients/csharp/Client.Core/src/HubConnection.cs @@ -1942,12 +1942,14 @@ namespace Microsoft.AspNetCore.SignalR.Client return _connectionLock.Wait(0); } + // Don't call this method in a try/finally that releases the lock since we're also potentially releasing the connection lock here. public async Task WaitForActiveConnectionAsync(string methodName, [CallerMemberName] string memberName = null, [CallerFilePath] string filePath = null, [CallerLineNumber] int lineNumber = 0) { await WaitConnectionLockAsync(methodName); if (CurrentConnectionStateUnsynchronized == null || CurrentConnectionStateUnsynchronized.Stopping) { + ReleaseConnectionLock(methodName); throw new InvalidOperationException($"The '{methodName}' method cannot be called if the connection is not active"); } diff --git a/src/SignalR/clients/csharp/Client/test/FunctionalTests/HubConnectionTests.cs b/src/SignalR/clients/csharp/Client/test/FunctionalTests/HubConnectionTests.cs index de1170f1bb..82e95d78c2 100644 --- a/src/SignalR/clients/csharp/Client/test/FunctionalTests/HubConnectionTests.cs +++ b/src/SignalR/clients/csharp/Client/test/FunctionalTests/HubConnectionTests.cs @@ -770,7 +770,6 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests } [Theory] - [Flaky("https://github.com/aspnet/AspNetCore-Internal/issues/2465", FlakyOn.All)] [MemberData(nameof(HubProtocolsAndTransportsAndHubPaths))] [LogLevel(LogLevel.Trace)] public async Task CanCancelIAsyncEnumerableClientToServerUpload(string protocolName, HttpTransportType transportType, string path)