@@ -26,13 +26,13 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
2626
2727 rejoiningAnimation : HTMLDivElement ;
2828
29- reloadButton : HTMLButtonElement ;
29+ retryButton : HTMLButtonElement ;
3030
3131 resumeButton : HTMLButtonElement ;
3232
3333 status : HTMLParagraphElement ;
3434
35- reconnect = true ;
35+ operation : ReconnectDisplayUpdateOptions [ 'type' ] = 'reconnect' ;
3636
3737 remote = false ;
3838
@@ -65,10 +65,10 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
6565 this . status = document . createElement ( 'p' ) ;
6666 this . status . innerHTML = '' ;
6767
68- this . reloadButton = document . createElement ( 'button' ) ;
69- this . reloadButton . style . display = 'none' ;
70- this . reloadButton . innerHTML = 'Retry' ;
71- this . reloadButton . addEventListener ( 'click' , this . retry . bind ( this ) ) ;
68+ this . retryButton = document . createElement ( 'button' ) ;
69+ this . retryButton . style . display = 'none' ;
70+ this . retryButton . innerHTML = 'Retry' ;
71+ this . retryButton . addEventListener ( 'click' , this . retry . bind ( this ) ) ;
7272
7373 this . resumeButton = document . createElement ( 'button' ) ;
7474 this . resumeButton . style . display = 'none' ;
@@ -77,7 +77,7 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
7777
7878 this . dialog . appendChild ( this . rejoiningAnimation ) ;
7979 this . dialog . appendChild ( this . status ) ;
80- this . dialog . appendChild ( this . reloadButton ) ;
80+ this . dialog . appendChild ( this . retryButton ) ;
8181 this . dialog . appendChild ( this . resumeButton ) ;
8282
8383 this . overlay . appendChild ( this . dialog ) ;
@@ -94,30 +94,30 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
9494 this . document . body . appendChild ( this . host ) ;
9595 }
9696
97- this . reconnect = options ?. type === 'reconnect' ;
97+ this . operation = options ?. type ?? 'reconnect' ;
9898
99- this . reloadButton . style . display = 'none' ;
99+ this . retryButton . style . display = 'none' ;
100100 this . rejoiningAnimation . style . display = 'block' ;
101101 this . status . innerHTML = 'Rejoining the server...' ;
102102 this . host . style . display = 'block' ;
103103 this . overlay . classList . add ( DefaultReconnectDisplay . ReconnectVisibleClassName ) ;
104104 }
105105
106106 update ( options : ReconnectDisplayUpdateOptions ) : void {
107- this . reconnect = options . type === 'reconnect' ;
108- if ( this . reconnect ) {
107+ this . operation = options . type ;
108+ if ( this . operation === 'pause' ) {
109+ this . retryButton . style . display = 'none' ;
110+ this . rejoiningAnimation . style . display = 'none' ;
111+ this . status . innerHTML = 'The session has been paused by the server.' ;
112+ this . resumeButton . style . display = 'block' ;
113+ } else {
109114 const { currentAttempt, secondsToNextAttempt } = options as ReconnectOptions ;
110115 if ( currentAttempt === 1 || secondsToNextAttempt === 0 ) {
111116 this . status . innerHTML = 'Rejoining the server...' ;
112117 } else {
113118 const unitText = secondsToNextAttempt === 1 ? 'second' : 'seconds' ;
114119 this . status . innerHTML = `Rejoin failed... trying again in ${ secondsToNextAttempt } ${ unitText } ` ;
115120 }
116- } else {
117- this . reloadButton . style . display = 'none' ;
118- this . rejoiningAnimation . style . display = 'none' ;
119- this . status . innerHTML = 'The session has been paused by the server.' ;
120- this . resumeButton . style . display = 'block' ;
121121 }
122122 }
123123
@@ -128,15 +128,15 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
128128
129129 failed ( ) : void {
130130 this . rejoiningAnimation . style . display = 'none' ;
131- if ( this . reconnect ) {
132- this . reloadButton . style . display = 'block' ;
131+ if ( this . operation === 'pause' ) {
132+ // The client expected to be able to resume the circuit and it failed.
133+ // This typically happens when the server has been restarted and the circuit state is lost.
134+ // This is effectively the same as the circuit being rejected during reconnect.
135+ this . rejected ( ) ;
136+ } else {
137+ this . retryButton . style . display = 'block' ;
133138 this . status . innerHTML = 'Failed to rejoin.<br />Please retry or reload the page.' ;
134139 this . document . addEventListener ( 'visibilitychange' , this . retryWhenDocumentBecomesVisible ) ;
135- } else {
136- // Resuming circuit failed, last resort is to reload the page.
137- // This enables automatic reconnection (with empty state) when the server is restarted,
138- // e.g. during local development.
139- location . reload ( ) ;
140140 }
141141 }
142142
@@ -161,7 +161,7 @@ export class DefaultReconnectDisplay implements ReconnectDisplay {
161161 this . update ( { type : 'pause' , remote : this . remote } ) ;
162162 const resumeSuccessful = await Blazor . resumeCircuit ! ( ) ;
163163 if ( ! resumeSuccessful ) {
164- this . rejected ( ) ;
164+ this . failed ( ) ;
165165 }
166166 }
167167 } catch ( err : unknown ) {
0 commit comments