Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Blazor] Updated Blazor Server reconnect UI #55723

Merged
merged 10 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/Components/Components.slnf
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"src\\Hosting\\Abstractions\\src\\Microsoft.AspNetCore.Hosting.Abstractions.csproj",
"src\\Hosting\\Hosting\\src\\Microsoft.AspNetCore.Hosting.csproj",
"src\\Hosting\\Server.Abstractions\\src\\Microsoft.AspNetCore.Hosting.Server.Abstractions.csproj",
"src\\Hosting\\TestHost\\src\\Microsoft.AspNetCore.TestHost.csproj",
"src\\Html.Abstractions\\src\\Microsoft.AspNetCore.Html.Abstractions.csproj",
"src\\Http\\Authentication.Abstractions\\src\\Microsoft.AspNetCore.Authentication.Abstractions.csproj",
"src\\Http\\Authentication.Core\\src\\Microsoft.AspNetCore.Authentication.Core.csproj",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ export function resolveOptions(userOptions?: Partial<CircuitStartOptions>): Circ
}

export interface ReconnectionOptions {
maxRetries: number;
retryIntervalMilliseconds: number;
maxRetries?: number;
retryIntervalMilliseconds: number | ((previousAttempts: number, maxRetries?: number) => number | undefined | null);
dialogId: string;
}

Expand All @@ -49,15 +49,34 @@ export interface ReconnectionHandler {
onConnectionUp(): void;
}

function computeDefaultRetryInterval(previousAttempts: number, maxRetries?: number): number | null {
if (maxRetries && previousAttempts >= maxRetries) {
return null;
}

if (previousAttempts < 10) {
// Retry as quickly as possible for the first 10 tries
return 0;
}

if (previousAttempts < 20) {
// Retry every 5 seconds for the next 10 tries
return 5000;
}

// Then retry every 30 seconds indefinitely
return 30000;
}

const defaultOptions: CircuitStartOptions = {
// eslint-disable-next-line @typescript-eslint/no-empty-function
configureSignalR: (_) => { },
logLevel: LogLevel.Warning,
initializers: undefined!,
circuitHandlers: [],
reconnectionOptions: {
maxRetries: 8,
retryIntervalMilliseconds: 20000,
maxRetries: 30,
retryIntervalMilliseconds: computeDefaultRetryInterval,
dialogId: 'components-reconnect-modal',
},
};
Loading
Loading