Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix polling

x03220512c813928c67
diff --git a/frontend/src/pages/admin/OverviewPage/components/CachingPanel.tsx b/frontend/src/pages/admin/OverviewPage/components/CachingPanel.tsx
index bb3277204e..8559f7a93b 100644
--- a/frontend/src/pages/admin/OverviewPage/components/CachingPanel.tsx
+++ b/frontend/src/pages/admin/OverviewPage/components/CachingPanel.tsx
@@ -14,12 +14,14 @@ export const CachingPanel = () => {
const { mutateAsync: invalidateCache } = useInvalidateCache();
const { user } = useUser();
- const shouldShowSuccessRef = useRef(false);
-
const [type, setType] = useState<CacheType | null>(null);
const [shouldPoll, setShouldPoll] = useState(false);
- const { data: invalidationStatus, isPending } = useGetInvalidatingCacheStatus(shouldPoll);
+ const {
+ data: invalidationStatus,
+ isPending,
+ refetch
+ } = useGetInvalidatingCacheStatus(shouldPoll);
const isInvalidating = Boolean(shouldPoll && !isPending && invalidationStatus);
const { popUp, handlePopUpOpen, handlePopUpClose, handlePopUpToggle } = usePopUp([
@@ -29,12 +31,16 @@ export const CachingPanel = () => {
const handleInvalidateCacheSubmit = async () => {
if (!type || isInvalidating) return;
- shouldShowSuccessRef.current = true;
try {
await invalidateCache({ type });
createNotification({ text: `Began invalidating ${type} cache`, type: "success" });
handlePopUpClose("invalidateCache");
- setShouldPoll(true);
+
+ refetch().then((v) =>
+ v
+ ? setShouldPoll(true)
+ : createNotification({ text: "Successfully invalidated cache", type: "success" })
+ );
} catch (err) {
console.error(err);
createNotification({ text: `Failed to invalidate ${type} cache`, type: "error" });
@@ -50,6 +56,10 @@ export const CachingPanel = () => {
}
}, [isInvalidating, shouldPoll]);
+ useEffect(() => {
+ refetch().then((v) => setShouldPoll(v.data || false));
+ }, []);
+
return (
<>
<div className="mb-6 flex flex-wrap items-end justify-between gap-4 rounded-lg border border-mineshaft-600 bg-mineshaft-900 p-4">