mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-07-21 13:03:41 +01:00
Fix issues with rare Remora bug
This commit is contained in:
@@ -603,9 +603,11 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
await Task.WhenAny(gatewayReadyTcs.Task, gatewayTask).ConfigureAwait(false);
|
||||
}
|
||||
|
||||
if (gatewayTask.IsCompleted)
|
||||
if (gatewayTask.IsCompleted || cancellationToken.IsCancellationRequested)
|
||||
{
|
||||
await DisconnectImpl(cancellationToken).ConfigureAwait(false);
|
||||
// DCT: Musn't abort
|
||||
await DisconnectImpl(default).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
throw new JobException(ErrorCode.ChatCannotConnectProvider);
|
||||
}
|
||||
|
||||
@@ -618,8 +620,9 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
Logger.LogWarning("Unable to retrieve current user: {0}", currentUserResult.Error.Message);
|
||||
|
||||
// will handle cleanup
|
||||
await DisconnectImpl(cancellationToken).ConfigureAwait(false);
|
||||
|
||||
// DCT: Musn't abort
|
||||
await DisconnectImpl(default).ConfigureAwait(false);
|
||||
cancellationToken.ThrowIfCancellationRequested();
|
||||
throw new JobException(ErrorCode.ChatCannotConnectProvider);
|
||||
}
|
||||
|
||||
@@ -627,8 +630,7 @@ namespace Tgstation.Server.Host.Components.Chat.Providers
|
||||
}
|
||||
catch (OperationCanceledException)
|
||||
{
|
||||
if (gatewayTask != null)
|
||||
await DisconnectImpl(default).ConfigureAwait(false); // DCT: Musn't abort
|
||||
throw;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
@@ -85,19 +85,6 @@ namespace Tgstation.Server.Host.Components.Chat.Providers.Tests
|
||||
|
||||
await provider.Disconnect(default).ConfigureAwait(false);
|
||||
Assert.IsFalse(provider.Connected);
|
||||
|
||||
//now try it with cancellationTokens
|
||||
using var cts = new CancellationTokenSource();
|
||||
cts.Cancel();
|
||||
var cancellationToken = cts.Token;
|
||||
await Assert.ThrowsExceptionAsync<OperationCanceledException>(() => InvokeConnect(provider, cancellationToken)).ConfigureAwait(false);
|
||||
Assert.IsFalse(provider.Connected);
|
||||
await InvokeConnect(provider).ConfigureAwait(false);
|
||||
Assert.IsTrue(provider.Connected);
|
||||
await Assert.ThrowsExceptionAsync<OperationCanceledException>(() => provider.Disconnect(cancellationToken)).ConfigureAwait(false);
|
||||
Assert.IsTrue(provider.Connected);
|
||||
await provider.Disconnect(default).ConfigureAwait(false);
|
||||
Assert.IsFalse(provider.Connected);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user