Skip to content

Commit 49b72df

Browse files
[main] [Blazor] Updated Blazor Server reconnect UI (#55951)
* Basic prototype * Updates * Styling improvements * Cleanup * Small change * Updates * Some small improvements * Remove custom CSS property * Allow retrying after `maxRetries` * Update comment --------- Co-authored-by: Mackinnon Buck <mackinnon.buck@gmail.com>
1 parent 05744ca commit 49b72df

File tree

8 files changed

+381
-159
lines changed

8 files changed

+381
-159
lines changed

src/Components/Components.slnf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@
7575
"src\\Hosting\\Abstractions\\src\\Microsoft.AspNetCore.Hosting.Abstractions.csproj",
7676
"src\\Hosting\\Hosting\\src\\Microsoft.AspNetCore.Hosting.csproj",
7777
"src\\Hosting\\Server.Abstractions\\src\\Microsoft.AspNetCore.Hosting.Server.Abstractions.csproj",
78+
"src\\Hosting\\TestHost\\src\\Microsoft.AspNetCore.TestHost.csproj",
7879
"src\\Html.Abstractions\\src\\Microsoft.AspNetCore.Html.Abstractions.csproj",
7980
"src\\Http\\Authentication.Abstractions\\src\\Microsoft.AspNetCore.Authentication.Abstractions.csproj",
8081
"src\\Http\\Authentication.Core\\src\\Microsoft.AspNetCore.Authentication.Core.csproj",

src/Components/Web.JS/src/Platform/Circuits/CircuitStartOptions.ts

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export function resolveOptions(userOptions?: Partial<CircuitStartOptions>): Circ
3434
}
3535

3636
export interface ReconnectionOptions {
37-
maxRetries: number;
38-
retryIntervalMilliseconds: number;
37+
maxRetries?: number;
38+
retryIntervalMilliseconds: number | ((previousAttempts: number, maxRetries?: number) => number | undefined | null);
3939
dialogId: string;
4040
}
4141

@@ -49,15 +49,34 @@ export interface ReconnectionHandler {
4949
onConnectionUp(): void;
5050
}
5151

52+
function computeDefaultRetryInterval(previousAttempts: number, maxRetries?: number): number | null {
53+
if (maxRetries && previousAttempts >= maxRetries) {
54+
return null;
55+
}
56+
57+
if (previousAttempts < 10) {
58+
// Retry as quickly as possible for the first 10 tries
59+
return 0;
60+
}
61+
62+
if (previousAttempts < 20) {
63+
// Retry every 5 seconds for the next 10 tries
64+
return 5000;
65+
}
66+
67+
// Then retry every 30 seconds indefinitely
68+
return 30000;
69+
}
70+
5271
const defaultOptions: CircuitStartOptions = {
5372
// eslint-disable-next-line @typescript-eslint/no-empty-function
5473
configureSignalR: (_) => { },
5574
logLevel: LogLevel.Warning,
5675
initializers: undefined!,
5776
circuitHandlers: [],
5877
reconnectionOptions: {
59-
maxRetries: 8,
60-
retryIntervalMilliseconds: 20000,
78+
maxRetries: 30,
79+
retryIntervalMilliseconds: computeDefaultRetryInterval,
6180
dialogId: 'components-reconnect-modal',
6281
},
6382
};

0 commit comments

Comments
 (0)