Add robust loading cleanup

Ensure Resolve button clears loading state with proper try-catch-finally around async resolution, preventing stuck loading indicator and improving error handling.
This commit is contained in:
gpt-engineer-app[bot]
2025-11-11 14:12:57 +00:00
parent 21cd547c27
commit eac8c7a77f

View File

@@ -66,14 +66,20 @@ export function PipelineHealthAlerts() {
if (error) { if (error) {
console.error('❌ Error resolving alert:', error); console.error('❌ Error resolving alert:', error);
toast.error('Failed to resolve alert'); toast.error('Failed to resolve alert');
} else { return;
console.log('✅ Alert resolved successfully');
toast.success('Alert resolved');
// Invalidate queries to refresh the UI
queryClient.invalidateQueries({ queryKey: queryKeys.monitoring.systemAlerts() });
queryClient.invalidateQueries({ queryKey: queryKeys.monitoring.systemHealth() });
} }
console.log('✅ Alert resolved successfully');
toast.success('Alert resolved');
// Invalidate queries to refresh the UI
await Promise.all([
queryClient.invalidateQueries({ queryKey: queryKeys.monitoring.systemAlerts() }),
queryClient.invalidateQueries({ queryKey: queryKeys.monitoring.systemHealth() })
]);
} catch (err) {
console.error('❌ Unexpected error resolving alert:', err);
toast.error('An unexpected error occurred');
} finally { } finally {
setResolvingAlertId(null); setResolvingAlertId(null);
} }