@@ -45,9 +45,6 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
4545 < div class ="small text-muted mb-4 " id ="progress-next-step ">
4646 We will open the app details page automatically when everything is ready.
4747 </ div >
48- < div class ="small text-warning d-none mb-4 " id ="progress-poll-warning ">
49- Could not load the latest deployment update. Retrying automatically.
50- </ div >
5148
5249 < div class ="d-flex flex-wrap gap-2 ">
5350 < a href ="{{ form_url }} " class ="btn btn-outline-secondary "> Back to form</ a >
@@ -75,6 +72,7 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
7572const ACTIVE_STATUS_POLL_MS = 3000 ;
7673const STABLE_STATUS_POLL_MS = 30000 ;
7774const ERROR_STATUS_POLL_MS = 10000 ;
75+ const REQUIRED_ERROR_POLLS = 3 ;
7876const TERMINAL_STEP_STATUSES = new Set ( [ "success" , "warning" , "failed" , "skipped" ] ) ;
7977const STEP_ROW_CLASS_BY_STATUS = {
8078 failed : "is-failed" ,
@@ -107,6 +105,7 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
107105let consecutiveSuccessPolls = 0 ;
108106let consecutiveErrorPolls = 0 ;
109107let stepRevealTimer = null ;
108+ let pageIsUnloading = false ;
110109let latestServerData = {
111110 deployment : {
112111 status : "{{ deployment.status|default:'pending'|escapejs }}" ,
@@ -132,13 +131,17 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
132131 }
133132}
134133
135- function updatePollWarning ( isVisible ) {
136- const warning = document . getElementById ( "progress-poll-warning " ) ;
137- if ( warning ) {
138- warning . classList . toggle ( "d-none" , ! isVisible ) ;
134+ function showInlinePollError ( ) {
135+ const inline = document . getElementById ( "progress-inline " ) ;
136+ if ( inline ) {
137+ inline . textContent = "Could not load the latest deployment update. Retrying automatically." ;
139138 }
140139}
141140
141+ function shouldIgnorePollError ( error ) {
142+ return pageIsUnloading || document . hidden || error ?. name === "AbortError" ;
143+ }
144+
142145function copyProgressData ( data = { } ) {
143146 return {
144147 deployment : { ...( data . deployment || { } ) } ,
@@ -378,6 +381,7 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
378381 }
379382 if ( ! successRedirectTimer ) {
380383 successRedirectTimer = window . setTimeout ( ( ) => {
384+ progressPoller ?. stop ( ) ;
381385 window . location . assign ( detailUrl ) ;
382386 } , SUCCESS_REDIRECT_DELAY_MS ) ;
383387 }
@@ -503,7 +507,6 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
503507 } )
504508 . then ( data => {
505509 consecutiveErrorPolls = 0 ;
506- updatePollWarning ( false ) ;
507510 const fresh = copyProgressData ( data ) ;
508511
509512 if ( isProgressSuccessful ( fresh ) ) {
@@ -527,9 +530,14 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
527530 return canSlowPoll ? STABLE_STATUS_POLL_MS : ACTIVE_STATUS_POLL_MS ;
528531 } )
529532 . catch ( error => {
533+ if ( shouldIgnorePollError ( error ) ) {
534+ return ERROR_STATUS_POLL_MS ;
535+ }
530536 console . error ( "Error fetching deployment progress:" , error ) ;
531537 consecutiveErrorPolls += 1 ;
532- updatePollWarning ( consecutiveErrorPolls >= 2 ) ;
538+ if ( consecutiveErrorPolls >= REQUIRED_ERROR_POLLS ) {
539+ showInlinePollError ( ) ;
540+ }
533541 throw error ;
534542 } ) ;
535543}
@@ -547,11 +555,19 @@ <h1 class="h3 mb-2 deployment-progress-title" id="progress-title">We are prepari
547555 displayedProgressData = copyProgressData ( latestServerData ) ;
548556 renderProgress ( displayedProgressData ) ;
549557 maybeRedirectToDetails ( displayedProgressData ) ;
558+ window . serveDeploymentProgressPoller ?. stop ( ) ;
550559 progressPoller = ServeAdaptivePolling . createPoller ( {
551560 poll : refreshProgress ,
552561 getDelay : delay => delay ,
553562 errorDelay : ERROR_STATUS_POLL_MS
554563 } ) ;
564+ window . serveDeploymentProgressPoller = progressPoller ;
565+ } ) ;
566+
567+ window . addEventListener ( "pagehide" , ( ) => {
568+ pageIsUnloading = true ;
569+ progressPoller ?. stop ( ) ;
570+ window . serveDeploymentProgressPoller ?. stop ( ) ;
555571} ) ;
556572</ script >
557573{% endblock %}
0 commit comments