Skip to content

Commit 22aa2c2

Browse files
authored
Fix disposed issue when app shut down (#1876)
* Fix disposed issue when app shut down * Update ServiceConnection.cs
1 parent 4609c43 commit 22aa2c2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Microsoft.Azure.SignalR/ServerConnections/ServiceConnection.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ private async Task<bool> SkipHandshakeResponse(ClientConnectionContext connectio
344344
return false;
345345
}
346346

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

0 commit comments

Comments
 (0)