Fix retry

This commit is contained in:
Owen
2025-06-04 16:05:41 -04:00
parent 8800ec9675
commit 875ec662ad

View File

@@ -4,7 +4,6 @@ import { useEnvContext } from "./useEnvContext";
import { import {
Container, Container,
GetDockerStatusResponse, GetDockerStatusResponse,
GetSiteResponse,
ListContainersResponse, ListContainersResponse,
TriggerFetchResponse TriggerFetchResponse
} from "@server/routers/site"; } from "@server/routers/site";
@@ -89,16 +88,13 @@ export function useDockerSocket(site: Site) {
AxiosResponse<ListContainersResponse> AxiosResponse<ListContainersResponse>
>(`/site/${site.siteId}/docker/containers`); >(`/site/${site.siteId}/docker/containers`);
setContainers(res.data.data); setContainers(res.data.data);
return; return res.data.data;
} catch (error: any) { } catch (error: any) {
attempt++; attempt++;
// Check if the error is a 425 (Too Early) status // Check if the error is a 425 (Too Early) status
if (error?.response?.status === 425) { if (error?.response?.status === 425) {
if (attempt < maxRetries) { if (attempt < maxRetries) {
// Ask the newt server to check containers
await fetchContainerList();
console.log( console.log(
`Containers not ready yet (attempt ${attempt}/${maxRetries}). Retrying in 250ms...` `Containers not ready yet (attempt ${attempt}/${maxRetries}). Retrying in 250ms...`
); );