Skip to content

Commit 356be02

Browse files
[Blazor] Don't invoke when connection closed (#31862)
1 parent 4051bb4 commit 356be02

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

dist/Release/blazor.server.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Platform/Circuits/CircuitManager.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { internalFunctions as navigationManagerFunctions } from '../../Services/NavigationManager';
22
import { toLogicalRootCommentElement, LogicalElement } from '../../Rendering/LogicalElements';
33
import { ServerComponentDescriptor } from '../../Services/ComponentDescriptorDiscovery';
4+
import { HubConnectionState } from '@microsoft/signalr';
45

56
export class CircuitDescriptor {
67
public circuitId?: string;
@@ -19,6 +20,9 @@ export class CircuitDescriptor {
1920
throw new Error('Circuit host not initialized.');
2021
}
2122

23+
if (reconnection.state !== HubConnectionState.Connected) {
24+
return Promise.resolve(false);
25+
}
2226
return reconnection.invoke<boolean>('ConnectCircuit', this.circuitId);
2327
}
2428

@@ -31,7 +35,9 @@ export class CircuitDescriptor {
3135
}
3236

3337
public async startCircuit(connection: signalR.HubConnection): Promise<boolean> {
34-
38+
if (connection.state !== HubConnectionState.Connected) {
39+
return false;
40+
}
3541
const result = await connection.invoke<string>(
3642
'StartCircuit',
3743
navigationManagerFunctions.getBaseURI(),

0 commit comments

Comments
 (0)