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
|
// exceptions have been handled in the Running task continuation by closing the channel with the exception
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_webSocket.Dispose();
|
||||||
|
}
|
||||||
|
|
||||||
Log.TransportStopped(_logger, null);
|
Log.TransportStopped(_logger, null);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -169,13 +169,22 @@ namespace Microsoft.AspNetCore.SignalR.Client.FunctionalTests
|
||||||
var restartTcs = new TaskCompletionSource<object>();
|
var restartTcs = new TaskCompletionSource<object>();
|
||||||
connection.Closed += async e =>
|
connection.Closed += async e =>
|
||||||
{
|
{
|
||||||
logger.LogInformation("Closed event triggered");
|
try
|
||||||
if (!restartTcs.Task.IsCompleted)
|
|
||||||
{
|
{
|
||||||
logger.LogInformation("Restarting connection");
|
logger.LogInformation("Closed event triggered");
|
||||||
await connection.StartAsync().OrTimeout();
|
if (!restartTcs.Task.IsCompleted)
|
||||||
logger.LogInformation("Restarted connection");
|
{
|
||||||
restartTcs.SetResult(null);
|
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