Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): keep a proxy 504 out of the connection-lost toast

Yudhi Armyndharis6d05a4a2340e
diff --git a/dashboard/src/components/Toast.test.ts b/dashboard/src/components/Toast.test.ts
index 0a6c6f439..df282696f 100644
--- a/dashboard/src/components/Toast.test.ts
+++ b/dashboard/src/components/Toast.test.ts
@@ -51,13 +51,14 @@ test("WebKit's 'Load failed' collapses into one connection-lost toast", () => {
assert.deepEqual(raise([['Load failed'], ['Load failed']]), [CONNECTION_LOST]);
});
-test('a proxy 504 collapses into one connection-lost toast like 502 and 503', () => {
+test('a proxy 502 or 503 collapses into one connection-lost toast, a 504 keeps its own', () => {
+ // A 504 is a proxy that stopped waiting on a reachable backend: the request may still be running.
assert.deepEqual(
raise([
- ['Save failed', 'HTTP 504'],
+ ['Import failed', 'HTTP 504'],
['Refresh failed', 'HTTP 504'],
]),
- [CONNECTION_LOST],
+ ['Import failed', 'Refresh failed'],
);
rtl.cleanup();
assert.deepEqual(
diff --git a/dashboard/src/components/Toast.tsx b/dashboard/src/components/Toast.tsx
index 8e66b9c47..b16d43750 100644
--- a/dashboard/src/components/Toast.tsx
+++ b/dashboard/src/components/Toast.tsx
@@ -49,14 +49,16 @@ export function ToastProvider({ children }: ToastProviderProps) {
(title: string, message?: string) => {
// Browser fetch rejections: Chromium 'Failed to fetch', Firefox 'NetworkError ...', WebKit exactly
// 'Load failed' (compared whole, so 'download failed ...' keeps its own toast). A proxy answering
- // 502/503/504 with a non-JSON body surfaces as exactly 'HTTP <status>' (see handleErrorResponse).
+ // 502/503 with a non-JSON body surfaces as exactly 'HTTP <status>' (see handleErrorResponse). A 504
+ // keeps its own toast: the proxy reached the backend and stopped waiting, so the request (an import,
+ // a restart) may still be running and the caller's title says which one.
const m = message?.toLowerCase().trim() ?? '';
const tl = title.toLowerCase().trim();
const isConnectionError =
m.includes('failed to fetch') ||
m.includes('networkerror') ||
m === 'load failed' ||
- /^http 50[234]$/.test(m) ||
+ /^http 50[23]$/.test(m) ||
tl.includes('failed to fetch') ||
tl.includes('networkerror') ||
tl === 'load failed';