Skip to content

Commit fe72e9e

Browse files
FIX (healthcheck): Clean up healthcheck interval receving when tab changed
1 parent 640ccea commit fe72e9e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

frontend/src/features/healthcheck/ui/HealthckeckAttemptsComponent.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,12 @@ export const HealthckeckAttemptsComponent = ({ database }: Props) => {
7979

8080
useEffect(() => {
8181
let interval: number | null = null;
82+
let isCancelled = false;
8283

8384
setIsHealthcheckConfigLoading(true);
8485
healthcheckConfigApi.getHealthcheckConfig(database.id).then((healthcheckConfig) => {
86+
if (isCancelled) return;
87+
8588
setIsHealthcheckConfigLoading(false);
8689

8790
if (healthcheckConfig.isHealthcheckEnabled) {
@@ -93,17 +96,18 @@ export const HealthckeckAttemptsComponent = ({ database }: Props) => {
9396
if (period === 'today') {
9497
interval = setInterval(() => {
9598
loadHealthcheckAttempts(false);
96-
}, 60_000); // 5 seconds
99+
}, 60_000);
97100
}
98101
}
99102
});
100103

101104
return () => {
105+
isCancelled = true;
102106
if (interval) {
103107
clearInterval(interval);
104108
}
105109
};
106-
}, [period]);
110+
}, [database.id, period]);
107111

108112
if (isHealthcheckConfigLoading) {
109113
return (

0 commit comments

Comments
 (0)