Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): report a proxy-timed-out restart as outcome unknown

Yudhi Armyndharis078bc1c5f2a6
diff --git a/dashboard/src/hooks/useRestartFlow.ts b/dashboard/src/hooks/useRestartFlow.ts
index b5cc41793..2c680aedd 100644
--- a/dashboard/src/hooks/useRestartFlow.ts
+++ b/dashboard/src/hooks/useRestartFlow.ts
@@ -2,7 +2,8 @@ import { useEffect, useRef, useState } from 'react';
import { infraApi } from '../services/api';
import { restartPollAttempts } from '../utils/restartPoll';
-export type RestartStatus = 'idle' | 'restarting' | 'waiting' | 'success' | 'error';
+// 'unknown': a proxy gave up waiting for the restart request, so whether it went through cannot be told.
+export type RestartStatus = 'idle' | 'restarting' | 'waiting' | 'success' | 'error' | 'unknown';
export interface RestartOpenRequest {
profiles: string[];
@@ -146,12 +147,20 @@ export function useRestartFlow(): RestartFlow {
warnings = [...(response.orchestration?.errors ?? []), ...(response.removal?.errors ?? [])];
setRestartWarnings(warnings);
} catch (err) {
- // An HTTP status (a proxy 502/503/504 included) means no shutdown was confirmed and the old
+ // An HTTP status (a proxy 503 included) means no shutdown was confirmed and the old
// process may still be serving, so a readiness poll would report a restart that never happened.
// Only a status-less network failure is the expected sign of the server going down mid-answer.
- if (typeof (err as { status?: unknown } | null)?.status === 'number') {
+ const failure = err as { status?: unknown; code?: unknown } | null;
+ if (typeof failure?.status === 'number') {
stopCountdown();
setRestartCountdown(0);
+ // A 504, or a 502 the gateway did not stamp with a code, came from a proxy that stopped waiting.
+ // The request may still be running (a first-time enable pulls an image before the restart), so
+ // this is neither a refusal nor something a readiness poll can settle: the old process answers.
+ if (failure.status === 504 || (failure.status === 502 && failure.code === undefined)) {
+ setRestartStatus('unknown');
+ return;
+ }
setRestartError(err instanceof Error ? err.message : String(err));
setRestartStatus('error');
return;
diff --git a/dashboard/src/i18n/locales/ar.json b/dashboard/src/i18n/locales/ar.json
index 12b9168f8..b4579d6d1 100644
--- a/dashboard/src/i18n/locales/ar.json
+++ b/dashboard/src/i18n/locales/ar.json
@@ -927,6 +927,7 @@
"dontClose": "يرجى عدم إغلاق هذه النافذة",
"successMsg": "الخادم يعمل مرة أخرى! ستُحدَّث الصفحة تلقائياً.",
"errorMsg": "لم يستجب الخادم بعد 30 ثانية. يرجى مراجعة سجلات Docker وإعادة التشغيل يدوياً.",
+ "outcomeUnknown": "انتهت مهلة الوكيل قبل أن يستجيب الخادم. قد تكون إعادة التشغيل لا تزال جارية؛ أعد تحميل الصفحة بعد دقيقة للتحقق.",
"reload": "إعادة تحميل الصفحة"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/de.json b/dashboard/src/i18n/locales/de.json
index 873b30027..ed6a04c9f 100644
--- a/dashboard/src/i18n/locales/de.json
+++ b/dashboard/src/i18n/locales/de.json
@@ -922,6 +922,7 @@
"dontClose": "Bitte schließe dieses Fenster nicht",
"successMsg": "Der Server ist wieder online! Die Seite wird automatisch neu geladen.",
"errorMsg": "Der Server hat nach 30 Sekunden nicht geantwortet. Prüfe die Docker-Protokolle und starte ihn manuell neu.",
+ "outcomeUnknown": "Der Proxy hat das Warten aufgegeben, bevor der Server geantwortet hat. Der Neustart läuft möglicherweise noch; lade die Seite in einer Minute neu, um es zu prüfen.",
"reload": "Seite neu laden"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/en.json b/dashboard/src/i18n/locales/en.json
index 44c11f039..45f341323 100644
--- a/dashboard/src/i18n/locales/en.json
+++ b/dashboard/src/i18n/locales/en.json
@@ -922,6 +922,7 @@
"dontClose": "Please do not close this window",
"successMsg": "Server is back online! The page will reload automatically.",
"errorMsg": "Server did not respond after 30 seconds. Please check the Docker logs and restart manually.",
+ "outcomeUnknown": "The proxy timed out before the server answered. The restart may still be in progress; reload in a minute to check.",
"reload": "Reload Page"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/es.json b/dashboard/src/i18n/locales/es.json
index 7b7e9ba86..d3ec08e80 100644
--- a/dashboard/src/i18n/locales/es.json
+++ b/dashboard/src/i18n/locales/es.json
@@ -908,6 +908,7 @@
"dontClose": "Por favor, no cierres esta ventana",
"successMsg": "¡El servidor volvió a estar en línea! La página se recargará automáticamente.",
"errorMsg": "El servidor no respondió tras 30 segundos. Revisa los logs de Docker y reinicia manualmente.",
+ "outcomeUnknown": "El proxy agotó el tiempo de espera antes de que el servidor respondiera. Es posible que el reinicio siga en curso; recarga la página en un minuto para comprobarlo.",
"reload": "Recargar página"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/fr.json b/dashboard/src/i18n/locales/fr.json
index 4f282d770..a1e2cea1a 100644
--- a/dashboard/src/i18n/locales/fr.json
+++ b/dashboard/src/i18n/locales/fr.json
@@ -908,6 +908,7 @@
"dontClose": "Veuillez ne pas fermer cette fenêtre",
"successMsg": "Le serveur est de nouveau en ligne ! La page va se recharger automatiquement.",
"errorMsg": "Le serveur n'a pas répondu après 30 secondes. Veuillez vérifier les journaux Docker et redémarrer manuellement.",
+ "outcomeUnknown": "Le proxy a expiré avant que le serveur ne réponde. Le redémarrage est peut-être encore en cours ; rechargez la page dans une minute pour vérifier.",
"reload": "Recharger la page"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/he.json b/dashboard/src/i18n/locales/he.json
index 8f09ef9da..e198d4387 100644
--- a/dashboard/src/i18n/locales/he.json
+++ b/dashboard/src/i18n/locales/he.json
@@ -909,6 +909,7 @@
"dontClose": "אין לסגור חלון זה",
"successMsg": "השרת חזר לפעולה! הדף ייטען מחדש אוטומטית.",
"errorMsg": "השרת לא הגיב לאחר 30 שניות. יש לבדוק את לוגי Docker ולאתחל ידנית.",
+ "outcomeUnknown": "ה-proxy הגיע לזמן הקצוב לפני שהשרת הגיב. ייתכן שהאתחול עדיין מתבצע; יש לטעון את הדף מחדש בעוד דקה כדי לבדוק.",
"reload": "טעינת הדף מחדש"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/hi.json b/dashboard/src/i18n/locales/hi.json
index fffa82383..24b94b3c1 100644
--- a/dashboard/src/i18n/locales/hi.json
+++ b/dashboard/src/i18n/locales/hi.json
@@ -922,6 +922,7 @@
"dontClose": "कृपया इस विंडो को बंद न करें",
"successMsg": "सर्वर वापस ऑनलाइन है! पृष्ठ स्वचालित रूप से पुनः लोड होगा।",
"errorMsg": "सर्वर ने 30 सेकंड के बाद जवाब नहीं दिया। कृपया Docker लॉग की जाँच करें और मैन्युअल रूप से पुनरारंभ करें।",
+ "outcomeUnknown": "सर्वर के जवाब देने से पहले प्रॉक्सी का समय समाप्त हो गया। पुनरारंभ अभी भी जारी हो सकता है; जाँचने के लिए एक मिनट बाद पृष्ठ पुनः लोड करें।",
"reload": "पृष्ठ पुनः लोड करें"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/it.json b/dashboard/src/i18n/locales/it.json
index 2f171ae8c..df5a77082 100644
--- a/dashboard/src/i18n/locales/it.json
+++ b/dashboard/src/i18n/locales/it.json
@@ -908,6 +908,7 @@
"dontClose": "Si prega di non chiudere questa finestra",
"successMsg": "Il server è di nuovo online! La pagina si ricaricherà automaticamente.",
"errorMsg": "Il server non ha risposto dopo 30 secondi. Controlla i log di Docker e riavvia manualmente.",
+ "outcomeUnknown": "Il proxy è andato in timeout prima che il server rispondesse. Il riavvio potrebbe essere ancora in corso; ricarica la pagina tra un minuto per verificare.",
"reload": "Ricarica Pagina"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/ko.json b/dashboard/src/i18n/locales/ko.json
index 46c4e67ca..c3cc5d98c 100644
--- a/dashboard/src/i18n/locales/ko.json
+++ b/dashboard/src/i18n/locales/ko.json
@@ -922,6 +922,7 @@
"dontClose": "이 창을 닫지 마세요",
"successMsg": "서버가 다시 온라인 상태입니다! 페이지가 자동으로 새로고침됩니다.",
"errorMsg": "서버가 30초 동안 응답하지 않았습니다. Docker 로그를 확인하고 수동으로 재시작하세요.",
+ "outcomeUnknown": "서버가 응답하기 전에 프록시 시간이 초과되었습니다. 재시작이 아직 진행 중일 수 있으니 1분 후 페이지를 새로고침하여 확인하세요.",
"reload": "페이지 새로고침"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/pt-BR.json b/dashboard/src/i18n/locales/pt-BR.json
index ebd3a1b43..0a748f1b4 100644
--- a/dashboard/src/i18n/locales/pt-BR.json
+++ b/dashboard/src/i18n/locales/pt-BR.json
@@ -908,6 +908,7 @@
"dontClose": "Por favor, não feche esta janela",
"successMsg": "O servidor voltou a ficar online! A página será recarregada automaticamente.",
"errorMsg": "O servidor não respondeu após 30 segundos. Verifique os logs do Docker e reinicie manualmente.",
+ "outcomeUnknown": "O proxy atingiu o tempo limite antes de o servidor responder. A reinicialização ainda pode estar em andamento; recarregue a página em um minuto para verificar.",
"reload": "Recarregar página"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/te.json b/dashboard/src/i18n/locales/te.json
index c1cb51e2f..9150bcf29 100644
--- a/dashboard/src/i18n/locales/te.json
+++ b/dashboard/src/i18n/locales/te.json
@@ -902,6 +902,7 @@
"dontClose": "దయచేసి ఈ విండోను మూసివేయవద్దు",
"successMsg": "సర్వర్ తిరిగి ఆన్‌లైన్‌లోకి వచ్చింది! పేజీ స్వయంచాలకంగా రీలోడ్ అవుతుంది.",
"errorMsg": "30 సెకన్ల తర్వాత కూడా సర్వర్ స్పందించలేదు. దయచేసి డోకర్ (Docker) లాగ్‌లను తనిఖీ చేసి, మాన్యువల్‌గా రీస్టార్ట్ చేయండి.",
+ "outcomeUnknown": "సర్వర్ స్పందించే ముందే ప్రాక్సీ సమయం ముగిసింది. రీస్టార్ట్ ఇంకా కొనసాగుతూ ఉండవచ్చు; తనిఖీ చేయడానికి ఒక నిమిషం తర్వాత పేజీని రీలోడ్ చేయండి.",
"reload": "పేజీని రీలోడ్ చేయి"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/tr.json b/dashboard/src/i18n/locales/tr.json
index 42207d5cf..96dfe83e0 100644
--- a/dashboard/src/i18n/locales/tr.json
+++ b/dashboard/src/i18n/locales/tr.json
@@ -922,6 +922,7 @@
"dontClose": "Lütfen bu pencereyi kapatmayın",
"successMsg": "Sunucu tekrar çevrimiçi! Sayfa otomatik olarak yeniden yüklenecektir.",
"errorMsg": "Sunucu 30 saniye sonra yanıt vermedi. Lütfen Docker kayıtlarını kontrol edin ve manuel olarak yeniden başlatın.",
+ "outcomeUnknown": "Sunucu yanıt vermeden önce proxy zaman aşımına uğradı. Yeniden başlatma hâlâ sürüyor olabilir; kontrol etmek için bir dakika sonra sayfayı yeniden yükleyin.",
"reload": "Sayfayı Yeniden Yükle"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/zh-CN.json b/dashboard/src/i18n/locales/zh-CN.json
index d05982bca..a59ea6f02 100644
--- a/dashboard/src/i18n/locales/zh-CN.json
+++ b/dashboard/src/i18n/locales/zh-CN.json
@@ -902,6 +902,7 @@
"dontClose": "请不要关闭此窗口",
"successMsg": "服务器已恢复在线!页面将自动重新加载。",
"errorMsg": "服务器在 30 秒后仍无响应。请检查 Docker 日志并手动重启。",
+ "outcomeUnknown": "服务器响应前代理已超时。重启可能仍在进行中;请在一分钟后重新加载页面查看。",
"reload": "重新加载页面"
},
"toasts": {
diff --git a/dashboard/src/i18n/locales/zh-HK.json b/dashboard/src/i18n/locales/zh-HK.json
index 3c5f98cf0..d5e946090 100644
--- a/dashboard/src/i18n/locales/zh-HK.json
+++ b/dashboard/src/i18n/locales/zh-HK.json
@@ -902,6 +902,7 @@
"dontClose": "請不要關閉此視窗",
"successMsg": "伺服器已重新上線!頁面將自動重新載入。",
"errorMsg": "伺服器在 30 秒後仍未回應。請檢查 Docker 記錄並手動重新啟動。",
+ "outcomeUnknown": "伺服器回應前代理已逾時。重新啟動可能仍在進行中;請在一分鐘後重新載入頁面查看。",
"reload": "重新載入頁面"
},
"toasts": {
diff --git a/dashboard/src/pages/Infrastructure.test.ts b/dashboard/src/pages/Infrastructure.test.ts
index 09e8f7c50..29fd2d5ee 100644
--- a/dashboard/src/pages/Infrastructure.test.ts
+++ b/dashboard/src/pages/Infrastructure.test.ts
@@ -707,6 +707,51 @@ test('a refused restart shows the server reason and never polls readiness', { ti
assert.equal(within(dialog).queryByText('Server ready'), null);
});
+test(
+ 'a proxy timeout on the restart request reports an unknown outcome, not a failure',
+ { timeout: 10_000 },
+ async () => {
+ const { screen, fireEvent, within } = rtl;
+ resetFetchCalls();
+ // The proxy stopped waiting while the gateway was still pulling an image: the restart may yet happen,
+ // and the old process still answers readiness, so neither a failure nor a poll tells the truth.
+ overrides = {
+ restart: () =>
+ new Response('<html><body>504 Gateway Time-out</body></html>', {
+ status: 504,
+ headers: { 'Content-Type': 'text/html' },
+ }),
+ };
+ // jsdom cannot navigate, so a reload reports itself through console.error; count those.
+ const navigations: string[] = [];
+ const consoleError = console.error;
+ console.error = (...args: unknown[]) => {
+ const text = args.map(a => (a instanceof Error ? a.message : String(a))).join(' ');
+ if (text.includes('navigation')) navigations.push(text);
+ else consoleError(...args);
+ };
+ try {
+ renderInfrastructure();
+ await screen.findByText('Database Configuration');
+ fireEvent.click(screen.getByRole('button', { name: 'Save Configuration' }));
+ const dialog = await screen.findByRole('dialog');
+ fireEvent.click(within(dialog).getByRole('button', { name: 'Restart Now' }));
+
+ await within(dialog).findByText(
+ 'The proxy timed out before the server answered. The restart may still be in progress; reload in a minute to check.',
+ );
+ assert.equal(within(dialog).queryByText('Restart failed'), null);
+ assert.equal(within(dialog).queryByText('HTTP 504'), null);
+ // Past the first readiness poll (3s) and the 2s reload a confirmed restart schedules.
+ await new Promise(resolve => setTimeout(resolve, 3500));
+ assert.equal(findFetchCall('GET', '/api/health/ready'), undefined);
+ assert.deepEqual(navigations, [], 'the page reloaded on its own');
+ } finally {
+ console.error = consoleError;
+ }
+ },
+);
+
test(
'services that failed to start are shown after the restart instead of reloading over them',
{ timeout: 15_000 },
diff --git a/dashboard/src/pages/Infrastructure.tsx b/dashboard/src/pages/Infrastructure.tsx
index 5a82388b2..d0305c3ec 100644
--- a/dashboard/src/pages/Infrastructure.tsx
+++ b/dashboard/src/pages/Infrastructure.tsx
@@ -816,7 +816,8 @@ export function Infrastructure() {
<>
{restartFlow.restartStatus === 'idle' && t('infrastructure.restart.idleTitle')}
{restartFlow.restartStatus === 'restarting' && t('infrastructure.restart.restartingTitle')}
- {restartFlow.restartStatus === 'waiting' && t('infrastructure.restart.waitingTitle')}
+ {(restartFlow.restartStatus === 'waiting' || restartFlow.restartStatus === 'unknown') &&
+ t('infrastructure.restart.waitingTitle')}
{restartFlow.restartStatus === 'success' && t('infrastructure.restart.successTitle')}
{restartFlow.restartStatus === 'error' && t('infrastructure.restart.errorTitle')}
</>
@@ -902,6 +903,15 @@ export function Infrastructure() {
</>
)}
+ {restartFlow.restartStatus === 'unknown' && (
+ <>
+ <p className="restart-error-msg">{t('infrastructure.restart.outcomeUnknown')}</p>
+ <button className="btn-primary" onClick={() => window.location.reload()}>
+ {t('infrastructure.restart.reload')}
+ </button>
+ </>
+ )}
+
{restartFlow.restartStatus === 'error' && (
<>
<p className="restart-error-msg">{restartFlow.restartError ?? t('infrastructure.restart.errorMsg')}</p>