From 1e035ac375a4d67c39d671efbfc174fbb8530f8d Mon Sep 17 00:00:00 2001 From: chihlasm Date: Sat, 14 Mar 2026 12:50:29 -0400 Subject: [PATCH] fix: move Date.now() out of render in ErrorBoundary to satisfy eslint purity rule The chunk-reload logic used Date.now() and sessionStorage during render, triggering react-hooks/purity. Moved to useEffect so side effects run after commit, fixing the CI lint failure. Co-Authored-By: Claude Opus 4.6 --- frontend/src/components/common/ErrorBoundary.tsx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/frontend/src/components/common/ErrorBoundary.tsx b/frontend/src/components/common/ErrorBoundary.tsx index 2df02dc5..dea0c53b 100644 --- a/frontend/src/components/common/ErrorBoundary.tsx +++ b/frontend/src/components/common/ErrorBoundary.tsx @@ -1,5 +1,5 @@ import * as Sentry from '@sentry/react' -import { type ReactNode } from 'react' +import { type ReactNode, useEffect, useRef } from 'react' import { Button } from '@/components/ui/Button' interface FallbackProps { @@ -18,17 +18,20 @@ function isChunkLoadError(error: Error): boolean { } function DefaultFallback({ error, resetError }: FallbackProps) { + const reloadingRef = useRef(false) + // Auto-reload on stale chunk errors (happens after deployments) - if (isChunkLoadError(error)) { + useEffect(() => { + if (!isChunkLoadError(error)) return const key = 'rf_boundary_chunk_reload' const lastReload = sessionStorage.getItem(key) const now = Date.now() if (!lastReload || now - Number(lastReload) > 10_000) { sessionStorage.setItem(key, String(now)) + reloadingRef.current = true window.location.reload() - return null } - } + }, [error]) return (