Skip to content

Commit 27f89f3

Browse files
committed
Use 'remote' flag to distinguish graceful and ungraceful circuit pauses
1 parent a864856 commit 27f89f3

File tree

6 files changed

+12
-19
lines changed

6 files changed

+12
-19
lines changed

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

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
3636

3737
remote = false;
3838

39-
graceful = false;
40-
4139
retryWhenDocumentBecomesVisible: () => void;
4240

4341
constructor(dialogId: string, private readonly document: Document, private readonly logger: Logger) {
@@ -97,7 +95,7 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
9795
}
9896

9997
this.operation = options?.type ?? 'reconnect';
100-
this.graceful = (options?.type === 'pause') ? options.graceful : false;
98+
this.remote = options?.type === 'pause' ? options?.remote : false;
10199

102100
this.retryButton.style.display = 'none';
103101
this.rejoiningAnimation.style.display = 'block';
@@ -108,7 +106,7 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
108106

109107
update(options: ReconnectDisplayUpdateOptions): void {
110108
this.operation = options.type;
111-
this.graceful = (options.type === 'pause') ? options.graceful : false;
109+
this.remote = options?.type === 'pause' ? options?.remote : false;
112110

113111
if (this.operation === 'pause') {
114112
this.retryButton.style.display = 'none';
@@ -134,15 +132,15 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
134132
failed(): void {
135133
this.rejoiningAnimation.style.display = 'none';
136134
if (this.operation === 'pause') {
137-
if (this.graceful) {
135+
if (this.remote) {
136+
// Circuit failed to resume after an ungraceful pause (e.g., server restart).
137+
// We treat this as non-recoverable rejection.
138+
this.rejected();
139+
} {
138140
// Circuit failed to resume after a graceful (client-requested) pause.
139141
// We show a retry UI to allow the user to try to continue without losing the state.
140142
this.resumeButton.style.display = 'block';
141143
this.status.innerHTML = 'Failed to resume.<br />Please retry or reload the page.';
142-
} else {
143-
// Circuit failed to resume after an ungraceful pause (e.g., server restart).
144-
// We treat this as non-recoverable rejection.
145-
this.rejected();
146144
}
147145
} else {
148146
this.retryButton.style.display = 'block';
@@ -169,7 +167,7 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
169167
const successful = await Blazor.reconnect!();
170168
if (!successful) {
171169
// Try to resume the circuit if the reconnect failed
172-
this.update({ type: 'pause', remote: this.remote, graceful: this.graceful });
170+
this.update({ type: 'pause', remote: this.remote });
173171
const resumeSuccessful = await Blazor.resumeCircuit!();
174172
if (!resumeSuccessful) {
175173
this.failed();

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ class ReconnectionProcess {
7575
const displayOptions: ReconnectDisplayUpdateOptions = {
7676
type: isGracefulPause ? 'pause' : 'reconnect',
7777
remote: this.isRemote,
78-
graceful: !!isGracefulPause,
7978
currentAttempt: 0,
8079
secondsToNextAttempt: 0,
8180
};
@@ -86,7 +85,6 @@ class ReconnectionProcess {
8685
this.reconnectDisplay.update({
8786
type: 'pause',
8887
remote: this.isRemote,
89-
graceful: true,
9088
});
9189
}
9290
}
@@ -128,7 +126,7 @@ class ReconnectionProcess {
128126
if (!result) {
129127
// Try to resume the circuit if the reconnect failed
130128
// If the server responded and refused to reconnect, stop auto-retrying.
131-
this.reconnectDisplay.update({ type: 'pause', remote: true, graceful: false });
129+
this.reconnectDisplay.update({ type: 'pause', remote: true });
132130
const resumeResult = await this.resumeCallback();
133131
if (resumeResult) {
134132
return;

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ export type ReconnectDisplayUpdateOptions = ReconnectOptions | PauseOptions;
1313

1414
export type PauseOptions = {
1515
type: 'pause',
16-
remote: boolean,
17-
graceful: boolean
16+
remote: boolean
1817
};
1918

2019
export type ReconnectOptions = {

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,4 @@ export interface ReconnectStateChangedEvent {
33
currentAttempt?: number;
44
secondsToNextAttempt?: number;
55
remote?: boolean;
6-
graceful?: boolean;
76
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,9 @@ export class UserSpecifiedDisplay implements ReconnectDisplay {
7171
}
7272
if (options.type === 'pause') {
7373
const remote = options.remote;
74-
const graceful = options.graceful;
7574
this.dialog.classList.remove(UserSpecifiedDisplay.ShowClassName, UserSpecifiedDisplay.RetryingClassName);
7675
this.dialog.classList.add(UserSpecifiedDisplay.PausedClassName);
77-
this.dispatchReconnectStateChangedEvent({ state: 'paused', remote: remote, graceful: graceful });
76+
this.dispatchReconnectStateChangedEvent({ state: 'paused', remote: remote });
7877
}
7978
}
8079

src/ProjectTemplates/Web.ProjectTemplates/content/BlazorWeb-CSharp/BlazorWebCSharp.1/Components/Layout/ReconnectModal.razor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function handleReconnectStateChanged(event) {
1515
reconnectModal.close();
1616
} else if (event.detail.state === "failed") {
1717
document.addEventListener("visibilitychange", retryWhenDocumentBecomesVisible);
18-
} else if (event.detail.state === "rejected" || (event.detail.state === "resume-failed" && !!event.detail.graceful)) {
18+
} else if (event.detail.state === "rejected" || (event.detail.state === "resume-failed" && event.detail.remote)) {
1919
location.reload();
2020
}
2121
}

0 commit comments

Comments
 (0)