Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,10 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
this.status.innerHTML = 'Failed to rejoin.<br />Please retry or reload the page.';
this.document.addEventListener('visibilitychange', this.retryWhenDocumentBecomesVisible);
} else {
this.status.innerHTML = 'Failed to resume the session.<br />Please reload the page.';
this.resumeButton.style.display = 'none';
this.reloadButton.style.display = 'none';
// Resuming circuit failed, last resort is to reload the page.
// This enables automatic reconnection (with empty state) when the server is restarted,
// e.g. during local development.
location.reload();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this cleans the state, should it be silent? Should we log to inform that the automatic reload has started?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know? We do location.reload() in other places without logging it. (Most people would not see the message anyway if they do not enable preserving logs on navigation in the browser.)

Maybe the comment is misleading. The state is "cleaned" implicitly simply because a hard refresh is performed. This is done mainly for the benefit of developers so that they can continue using the page they are working on as soon as the server restarts.

Copy link
Member

@ilonatommy ilonatommy Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Initial behavior was to rely on the user to reload, now it's automatic. Can it happen that we get into failed because of a server error and get into reload loop? E.g. 500 -> reload -> 500 -> reload? I mean: if something unexpected like this happens, we should leave some tools for investigation.

Copy link
Member Author

@oroztocil oroztocil Nov 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not very obvious because the flag that controls this is not-very-descriptively named reconnect but the else branch (that does the reloading) is executed exactly only in the scenario where we try to resume state and it fails (because the new server instance does not have any state persisted for the circuit). It does not happen on a failed circuit start or a circuit reconnection. It does not happen when the server is not available.

Hard reloading the page means starting from scratch (just with the current URL). After the reload we are no longer in either a reconnection nor a resuming scenario. We can get a 404, we can get a new Blazor session, we can probably get some weird states in between - but we do not get a loop, at least not because of this line of code.

Before .NET 10, there was no state resuming so we cannot compare the behavior directly. However, we have been doing location.reload() when a reconnection attempt is rejected - which happened in the same scenarios as the failed state resuming now.

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ function handleReconnectStateChanged(event) {
reconnectModal.close();
} else if (event.detail.state === "failed") {
document.addEventListener("visibilitychange", retryWhenDocumentBecomesVisible);
} else if (event.detail.state === "rejected") {
} else if (event.detail.state === "rejected" || event.detail.state === "resume-failed") {
location.reload();
}
}
Expand Down
Loading