Skip to content

Commit f18e56d

Browse files
committed
feat: resolved memory leak
1 parent fce82d5 commit f18e56d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

frontend/src/pages/public/ErrorPage/ErrorPage.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,17 @@ export const ErrorPage = ({ error }: ErrorComponentProps) => {
1616
const reloadCount = parseInt(sessionStorage.getItem("vitePreloadErrorCount") || "0", 10);
1717

1818
useEffect(() => {
19+
let timeout: NodeJS.Timeout | null = null;
1920
if (isDeploymentSkew && reloadCount <= 3) {
20-
const timeout = setTimeout(() => {
21-
clearTimeout(timeout);
21+
timeout = setTimeout(() => {
22+
if (timeout) clearTimeout(timeout);
2223
sessionStorage.setItem("vitePreloadErrorCount", (reloadCount + 1).toString());
2324
window.location.reload();
2425
}, 10000);
2526
}
27+
return () => {
28+
if (timeout) clearTimeout(timeout);
29+
};
2630
}, [isDeploymentSkew]);
2731

2832
if (

0 commit comments

Comments
 (0)