mirror of
https://github.com/immich-app/immich.git
synced 2025-12-23 09:15:05 +03:00
refactor: use while loop rather than recursive calls
This commit is contained in:
@@ -34,6 +34,8 @@ export const loadMaintenanceAuth = async () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const loadMaintenanceStatus = async () => {
|
export const loadMaintenanceStatus = async () => {
|
||||||
|
let loaded = false;
|
||||||
|
while (!loaded) {
|
||||||
try {
|
try {
|
||||||
const status = await maintenanceStatus();
|
const status = await maintenanceStatus();
|
||||||
maintenanceStore.status.set(status);
|
maintenanceStore.status.set(status);
|
||||||
@@ -46,8 +48,11 @@ export const loadMaintenanceStatus = async () => {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
const status = (error as { status: number })?.status;
|
const status = (error as { status: number })?.status;
|
||||||
if (status && status >= 500 && status < 600) {
|
if (status && status >= 500 && status < 600) {
|
||||||
await new Promise((r) => setTimeout(r, 1e3));
|
await new Promise((resolve) => setTimeout(resolve, 1000));
|
||||||
await loadMaintenanceStatus();
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
throw error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user