Prevent white screen: wrap ActivityFeed in error boundary and improve ClientProviders error handling
This commit is contained in:
@@ -31,20 +31,39 @@ export default function ClientProviders({
|
||||
setMounted(true);
|
||||
// Check if we're on a 404 page by looking for the data attribute or pathname
|
||||
const check404 = () => {
|
||||
if (typeof window !== "undefined") {
|
||||
const has404Component = document.querySelector('[data-404-page]');
|
||||
const is404Path = pathname === '/404' || window.location.pathname === '/404' || window.location.pathname.includes('404');
|
||||
setIs404Page(!!has404Component || is404Path);
|
||||
try {
|
||||
if (typeof window !== "undefined" && typeof document !== "undefined") {
|
||||
const has404Component = document.querySelector('[data-404-page]');
|
||||
const is404Path = pathname === '/404' || (window.location && (window.location.pathname === '/404' || window.location.pathname.includes('404')));
|
||||
setIs404Page(!!has404Component || is404Path);
|
||||
}
|
||||
} catch (error) {
|
||||
// Silently fail - 404 detection is not critical
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.warn('Error checking 404 status:', error);
|
||||
}
|
||||
}
|
||||
};
|
||||
// Check immediately and after a short delay
|
||||
check404();
|
||||
const timeout = setTimeout(check404, 100);
|
||||
const interval = setInterval(check404, 500);
|
||||
return () => {
|
||||
clearTimeout(timeout);
|
||||
clearInterval(interval);
|
||||
};
|
||||
try {
|
||||
check404();
|
||||
const timeout = setTimeout(check404, 100);
|
||||
const interval = setInterval(check404, 500);
|
||||
return () => {
|
||||
try {
|
||||
clearTimeout(timeout);
|
||||
clearInterval(interval);
|
||||
} catch {
|
||||
// Silently fail during cleanup
|
||||
}
|
||||
};
|
||||
} catch (error) {
|
||||
// If setup fails, just return empty cleanup
|
||||
if (process.env.NODE_ENV === 'development') {
|
||||
console.warn('Error setting up 404 check:', error);
|
||||
}
|
||||
return () => {};
|
||||
}
|
||||
}, [pathname]);
|
||||
|
||||
// Wrap in multiple error boundaries to isolate failures
|
||||
|
||||
Reference in New Issue
Block a user