File size: 475 Bytes
4e1096a
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export const handleGlobalError = (e: Error) => {
  const isChunkError = e?.message?.includes('Loading chunk');

  if (!isChunkError) {
    const now = Date.now();
    const lastReload = Number(sessionStorage.getItem('lastErrorReload') || '0');
    if (now - lastReload > 60_000) {
      sessionStorage.setItem('lastErrorReload', String(now));
      window.location.reload();
    } else {
      console.warn('Error detected, but reload suppressed (rate limit)');
    }
  }
};