From ab4b6ea273e52ca398e55116c7dda2ed2d46f53f Mon Sep 17 00:00:00 2001 From: Cyrus Goh Date: Tue, 10 Dec 2024 14:35:49 +0800 Subject: [PATCH] stop polling when reconcile error --- .../projects/status/ProjectResources.svelte | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/web-admin/src/features/projects/status/ProjectResources.svelte b/web-admin/src/features/projects/status/ProjectResources.svelte index ed29d8e91c4..4d4f010b825 100644 --- a/web-admin/src/features/projects/status/ProjectResources.svelte +++ b/web-admin/src/features/projects/status/ProjectResources.svelte @@ -21,6 +21,7 @@ let maxRefetchAttempts = 60; // 30 seconds maximum let refetchAttempts = 0; let pollInterval: ReturnType | null = null; + let individualRefresh = false; $: allResources = createRuntimeServiceListResources( $runtime.instanceId, @@ -54,13 +55,28 @@ ), ); + $: hasReconcileError = Boolean( + $allResources?.data?.some((resource) => !!resource.meta.reconcileError), + ); + function startPolling() { - stopPolling(); // Clear any existing interval + stopPolling(); refetchAttempts = 0; pollInterval = setInterval(() => { refetchAttempts++; + // Check for reconcile error during polling + if (individualRefresh && hasReconcileError) { + stopPolling(); + + // Refetch resources for latest reconcile status + void $allResources.refetch(); + + individualRefresh = false; + return; + } + if (refetchAttempts >= maxRefetchAttempts) { stopPolling(); return; @@ -97,7 +113,8 @@ ); } - function triggerRefresh() { + function refreshResource() { + individualRefresh = true; startPolling(); void $allResources.refetch(); } @@ -132,7 +149,10 @@ Error loading resources: {$allResources.error?.message} {:else if $allResources.data} - + {/if}