Skip to content

Commit fea352d

Browse files
committed
More cleanup
1 parent cd67e57 commit fea352d

File tree

2 files changed

+7
-16
lines changed

2 files changed

+7
-16
lines changed

src/Components/Server/src/ComponentHub.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,21 +43,22 @@ public ComponentHub(IServiceProvider services, ILogger<ComponentHub> logger)
4343
internal CircuitHost CircuitHost
4444
{
4545
get => (CircuitHost)Context.Items[CircuitKey];
46-
set => Context.Items[CircuitKey] = value;
46+
private set => Context.Items[CircuitKey] = value;
4747
}
4848

4949
/// <summary>
5050
/// Intended for framework use only. Applications should not call this method directly.
5151
/// </summary>
52-
public override async Task OnDisconnectedAsync(Exception exception)
52+
public override Task OnDisconnectedAsync(Exception exception)
5353
{
5454
var circuitHost = CircuitHost;
5555
if (circuitHost == null)
5656
{
57-
return;
57+
return Task.CompletedTask;
5858
}
5959

60-
await _circuitRegistry.DisconnectAsync(circuitHost, Context.ConnectionId);
60+
CircuitHost = null;
61+
return _circuitRegistry.DisconnectAsync(circuitHost, Context.ConnectionId);
6162
}
6263

6364
/// <summary>
@@ -122,7 +123,7 @@ private async void CircuitHost_UnhandledException(object sender, UnhandledExcept
122123
try
123124
{
124125
_logger.LogWarning((Exception)e.ExceptionObject, "Unhandled Server-Side exception");
125-
await circuitHost.Client.Client.SendAsync("JS.Error", e.ExceptionObject);
126+
await circuitHost.Client.SendAsync("JS.Error", e.ExceptionObject);
126127

127128
// We generally can't abort the connection here since this is an async
128129
// callback. The Hub has already been torn down. We'll rely on the
@@ -139,7 +140,7 @@ private CircuitHost EnsureCircuitHost()
139140
var circuitHost = CircuitHost;
140141
if (circuitHost == null)
141142
{
142-
var message = "The circuit state is invalid. This is due to an exception thrown during initialization or due to a timeout when reconnecting to it.";
143+
var message = $"The {nameof(CircuitHost)} is null. This is due to an exception thrown during initialization.";
143144
throw new InvalidOperationException(message);
144145
}
145146

src/Components/Server/src/LoggerExtensions.cs

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)