Skip to content

Commit

Permalink
Fix disposed issue when app shut down (#1876)
Browse files Browse the repository at this point in the history
* Fix disposed issue when app shut down

* Update ServiceConnection.cs
  • Loading branch information
vicancy authored Dec 6, 2023
1 parent 4609c43 commit 22aa2c2
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ private async Task<bool> SkipHandshakeResponse(ClientConnectionContext connectio
return false;
}

private async Task ProcessOutgoingMessagesAsync(ClientConnectionContext connection, CancellationToken token = default)
private async Task ProcessOutgoingMessagesAsync(ClientConnectionContext connection, CancellationToken token)
{
try
{
Expand Down Expand Up @@ -430,6 +430,11 @@ private async Task ProcessApplicationTaskAsyncCore(ClientConnectionContext conne
// application task can end when exception, or Context.Abort() from hub
await _connectionDelegate(connection);
}
catch (ObjectDisposedException)
{
// When the application shuts down and disposes IServiceProvider, HubConnectionHandler.RunHubAsync is still running and runs into _dispatcher.OnDisconnectedAsync
// no need to throw the error out
}
catch (Exception ex)
{
// Capture the exception to communicate it to the transport (this isn't strictly required)
Expand Down

0 comments on commit 22aa2c2

Please sign in to comment.