refactor: use while loop rather than recursive calls

This commit is contained in:
izzy
2025-11-24 15:31:07 +00:00
parent b99d92961c
commit 1ad2282166

View File

@@ -34,6 +34,8 @@ export const loadMaintenanceAuth = async () => {
};
export const loadMaintenanceStatus = async () => {
let loaded = false;
while (!loaded) {
try {
const status = await maintenanceStatus();
maintenanceStore.status.set(status);
@@ -46,8 +48,11 @@ export const loadMaintenanceStatus = async () => {
} catch (error) {
const status = (error as { status: number })?.status;
if (status && status >= 500 && status < 600) {
await new Promise((r) => setTimeout(r, 1e3));
await loadMaintenanceStatus();
await new Promise((resolve) => setTimeout(resolve, 1000));
continue;
}
throw error;
}
}
};