mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-07 05:27:48 +00:00
frontend tweaks
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { TKeyStoreFactory } from "@app/keystore/keystore";
|
import { TKeyStoreFactory } from "@app/keystore/keystore";
|
||||||
import { delay } from "@app/lib/delay";
|
|
||||||
import { logger } from "@app/lib/logger";
|
import { logger } from "@app/lib/logger";
|
||||||
import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
|
import { QueueJobs, QueueName, TQueueServiceFactory } from "@app/queue";
|
||||||
|
|
||||||
@@ -19,14 +18,6 @@ export const invalidateCacheQueueFactory = ({ queueService, keyStore }: TInvalid
|
|||||||
type: CacheType;
|
type: CacheType;
|
||||||
};
|
};
|
||||||
}) => {
|
}) => {
|
||||||
// Cancel existing jobs if any
|
|
||||||
try {
|
|
||||||
console.log("stopping job");
|
|
||||||
await queueService.clearQueue(QueueName.InvalidateCache);
|
|
||||||
} catch (err) {
|
|
||||||
logger.warn(err, "Failed to clear queue");
|
|
||||||
}
|
|
||||||
|
|
||||||
await queueService.queue(QueueName.InvalidateCache, QueueJobs.InvalidateCache, dto, {
|
await queueService.queue(QueueName.InvalidateCache, QueueJobs.InvalidateCache, dto, {
|
||||||
removeOnComplete: true,
|
removeOnComplete: true,
|
||||||
removeOnFail: true,
|
removeOnFail: true,
|
||||||
@@ -40,15 +31,11 @@ export const invalidateCacheQueueFactory = ({ queueService, keyStore }: TInvalid
|
|||||||
data: { type }
|
data: { type }
|
||||||
} = job.data;
|
} = job.data;
|
||||||
|
|
||||||
await keyStore.setItemWithExpiry("invalidating-cache", 3600, "true"); // 1 hour max (in case the job somehow silently fails)
|
await keyStore.setItemWithExpiry("invalidating-cache", 1800, "true"); // 30 minutes max (in case the job somehow silently fails)
|
||||||
|
|
||||||
console.log("STARTING JOB");
|
|
||||||
|
|
||||||
if (type === CacheType.ALL || type === CacheType.SECRETS)
|
if (type === CacheType.ALL || type === CacheType.SECRETS)
|
||||||
await keyStore.deleteItems({ pattern: "secret-manager:*" });
|
await keyStore.deleteItems({ pattern: "secret-manager:*" });
|
||||||
|
|
||||||
// await delay(12000); // TODO(andrey): Remove. It's for debug
|
|
||||||
|
|
||||||
await keyStore.deleteItem("invalidating-cache");
|
await keyStore.deleteItem("invalidating-cache");
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
logger.error(err, "Failed to invalidate cache");
|
logger.error(err, "Failed to invalidate cache");
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ export const CachingPanel = () => {
|
|||||||
useGetInvalidatingCacheStatus();
|
useGetInvalidatingCacheStatus();
|
||||||
const { membership } = useOrgPermission();
|
const { membership } = useOrgPermission();
|
||||||
|
|
||||||
const wasInvalidating = useRef(false);
|
const ignoreInitial = useRef(true);
|
||||||
const [type, setType] = useState<CacheType | null>(null);
|
const [type, setType] = useState<CacheType | null>(null);
|
||||||
const [buttonsDisabled, setButtonsDisabled] = useState(false);
|
const [buttonsDisabled, setButtonsDisabled] = useState(false);
|
||||||
|
|
||||||
@@ -47,8 +47,6 @@ export const CachingPanel = () => {
|
|||||||
try {
|
try {
|
||||||
await invalidateCache({ type });
|
await invalidateCache({ type });
|
||||||
|
|
||||||
wasInvalidating.current = true;
|
|
||||||
|
|
||||||
createNotification({
|
createNotification({
|
||||||
text: `Began invalidating ${type} cache`,
|
text: `Began invalidating ${type} cache`,
|
||||||
type: "success"
|
type: "success"
|
||||||
@@ -98,10 +96,18 @@ export const CachingPanel = () => {
|
|||||||
};
|
};
|
||||||
}, [isInvalidating]);
|
}, [isInvalidating]);
|
||||||
|
|
||||||
|
// Helper to ignore the initial useEffect calls for isInvalidating
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isInvalidating === false && wasInvalidating.current) {
|
const timer = setTimeout(() => {
|
||||||
|
ignoreInitial.current = false;
|
||||||
|
}, 1000);
|
||||||
|
|
||||||
|
return () => clearTimeout(timer);
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!ignoreInitial.current && isInvalidating === false) {
|
||||||
success();
|
success();
|
||||||
wasInvalidating.current = false;
|
|
||||||
|
|
||||||
if (pollingRef.current) clearInterval(pollingRef.current);
|
if (pollingRef.current) clearInterval(pollingRef.current);
|
||||||
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
if (timeoutRef.current) clearTimeout(timeoutRef.current);
|
||||||
|
|||||||
Reference in New Issue
Block a user