@@ -43,21 +43,22 @@ public ComponentHub(IServiceProvider services, ILogger<ComponentHub> logger)
43
43
internal CircuitHost CircuitHost
44
44
{
45
45
get => ( CircuitHost ) Context . Items [ CircuitKey ] ;
46
- set => Context . Items [ CircuitKey ] = value ;
46
+ private set => Context . Items [ CircuitKey ] = value ;
47
47
}
48
48
49
49
/// <summary>
50
50
/// Intended for framework use only. Applications should not call this method directly.
51
51
/// </summary>
52
- public override async Task OnDisconnectedAsync ( Exception exception )
52
+ public override Task OnDisconnectedAsync ( Exception exception )
53
53
{
54
54
var circuitHost = CircuitHost ;
55
55
if ( circuitHost == null )
56
56
{
57
- return ;
57
+ return Task . CompletedTask ;
58
58
}
59
59
60
- await _circuitRegistry . DisconnectAsync ( circuitHost , Context . ConnectionId ) ;
60
+ CircuitHost = null ;
61
+ return _circuitRegistry . DisconnectAsync ( circuitHost , Context . ConnectionId ) ;
61
62
}
62
63
63
64
/// <summary>
@@ -122,7 +123,7 @@ private async void CircuitHost_UnhandledException(object sender, UnhandledExcept
122
123
try
123
124
{
124
125
_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 ) ;
126
127
127
128
// We generally can't abort the connection here since this is an async
128
129
// callback. The Hub has already been torn down. We'll rely on the
@@ -139,7 +140,7 @@ private CircuitHost EnsureCircuitHost()
139
140
var circuitHost = CircuitHost ;
140
141
if ( circuitHost == null )
141
142
{
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.";
143
144
throw new InvalidOperationException ( message ) ;
144
145
}
145
146
0 commit comments