Skip to content

Free, Open Source, Self-Hosted WhatsApp API Gateway

fix(dashboard): report an unanswered restart request as unknown

Yudhi Armyndharisb0cbc03d3dc1
diff --git a/dashboard/src/hooks/useRestartFlow.test.ts b/dashboard/src/hooks/useRestartFlow.test.ts
index bfe07e8da..95a42b4f9 100644
--- a/dashboard/src/hooks/useRestartFlow.test.ts
+++ b/dashboard/src/hooks/useRestartFlow.test.ts
@@ -348,7 +348,7 @@ test('a readiness attempt that hangs is given up on and the next one is made bef
assert.equal(result.current.restartStatus, 'success');
});
-test('a restart request that never answers ends in the error view at its bound, with no readiness poll', async () => {
+test('a restart request that never answers ends with the outcome unknown at its bound, with no readiness poll', async () => {
mock.timers.enable({ apis: ['setTimeout', 'setInterval', 'Date'], now: 1800000000000 });
restartAnswer = signal => abortReady(deferred().promise, signal);
const { result } = rtl.renderHook(() => useRestartFlow());
@@ -366,7 +366,7 @@ test('a restart request that never answers ends in the error view at its bound,
mock.timers.tick(61 * 1000);
await settleRestartReply();
});
- assert.equal(result.current.restartStatus, 'error');
+ assert.equal(result.current.restartStatus, 'unknown');
assert.equal(result.current.restartError, null);
assert.equal(result.current.restartCountdown, 0);
await rtl.act(async () => {
diff --git a/dashboard/src/hooks/useRestartFlow.ts b/dashboard/src/hooks/useRestartFlow.ts
index 68a0bf133..ed12b3c21 100644
--- a/dashboard/src/hooks/useRestartFlow.ts
+++ b/dashboard/src/hooks/useRestartFlow.ts
@@ -2,8 +2,6 @@ import { useEffect, useRef, useState } from 'react';
import { infraApi } from '../services/api';
import { restartPollAttempts } from '../utils/restartPoll';
-// 'unknown': a proxy answered in the gateway's place (a 504, a Cloudflare 52x, or a 502 with no gateway
-// code), so whether the restart went through cannot be told.
// One readiness request is given this long before it counts as a failed attempt and the next one is made; the
// elapsed deadline of the whole wait is still what ends it.
const READINESS_ATTEMPT_TIMEOUT_MS = 5000;
@@ -11,6 +9,9 @@ const READINESS_ATTEMPT_TIMEOUT_MS = 5000;
// the restarting view has no close button.
const RESTART_REQUEST_TIMEOUT_MS = 5 * 60 * 1000;
+// 'unknown': a proxy answered in the gateway's place (a 504, a Cloudflare 52x, or a 502 with no gateway
+// code), or the restart request was given up on without an answer, so whether the restart went through
+// cannot be told.
export type RestartStatus = 'idle' | 'restarting' | 'waiting' | 'success' | 'error' | 'unknown';
export interface RestartOpenRequest {
@@ -218,11 +219,12 @@ export function useRestartFlow(): RestartFlow {
setRestartWarnings(warnings);
} catch (err) {
if (!isCurrent()) return;
- // Given up on after its bound: the server never answered, which the poll below could only misread.
+ // Given up on after its bound: the server awaits its container work before it answers and shuts down, so it
+ // may still restart. Not a failure, and not something the poll below could settle: the old process answers.
if (request.signal.aborted) {
stopCountdown();
setRestartCountdown(0);
- setRestartStatus('error');
+ setRestartStatus('unknown');
return;
}
// An HTTP status (a proxy 503 included) means no shutdown was confirmed and the old