Found these while looking at a flaky test (#1871)
- Fix crashing test - Dispose the ClientWebsocket in StopAsync
This commit is contained in:
parent
b9e88923e7
commit
39f693b9ed
|
|
@ -356,6 +356,10 @@ namespace Microsoft.AspNetCore.Http.Connections.Client.Internal
|
|||
// exceptions have been handled in the Running task continuation by closing the channel with the exception
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
_webSocket.Dispose();
|
||||
}
|
||||
|
||||
Log.TransportStopped(_logger, null);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -169,13 +169,22 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
|||
var restartTcs = new TaskCompletionSource<object>();
|
||||
connection.Closed += async e =>
|
||||
{
|
||||
logger.LogInformation("Closed event triggered");
|
||||
if (!restartTcs.Task.IsCompleted)
|
||||
try
|
||||
{
|
||||
logger.LogInformation("Restarting connection");
|
||||
await connection.StartAsync().OrTimeout();
|
||||
logger.LogInformation("Restarted connection");
|
||||
restartTcs.SetResult(null);
|
||||
logger.LogInformation("Closed event triggered");
|
||||
if (!restartTcs.Task.IsCompleted)
|
||||
{
|
||||
logger.LogInformation("Restarting connection");
|
||||
await connection.StartAsync().OrTimeout();
|
||||
logger.LogInformation("Restarted connection");
|
||||
restartTcs.SetResult(null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// It's important to try catch here since this happens
|
||||
// on a thread pool thread
|
||||
restartTcs.TrySetException(ex);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue