From 9cc03bc4759e744b70fc444d41c1fc84521abc17 Mon Sep 17 00:00:00 2001 From: denshooter Date: Sat, 10 Jan 2026 17:08:16 +0100 Subject: [PATCH] Prevent white screen: wrap ActivityFeed in error boundary and improve ClientProviders error handling --- app/components/ClientProviders.tsx | 41 ++++++++++++++++++++++-------- app/page.tsx | 13 ++++++++-- 2 files changed, 41 insertions(+), 13 deletions(-) diff --git a/app/components/ClientProviders.tsx b/app/components/ClientProviders.tsx index 59a9ed8..62e5d30 100644 --- a/app/components/ClientProviders.tsx +++ b/app/components/ClientProviders.tsx @@ -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 diff --git a/app/page.tsx b/app/page.tsx index cd1be6e..8c71194 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -7,9 +7,16 @@ import Projects from "./components/Projects"; import Contact from "./components/Contact"; import Footer from "./components/Footer"; import Script from "next/script"; -import ActivityFeed from "./components/ActivityFeed"; +import dynamic from "next/dynamic"; +import ErrorBoundary from "@/components/ErrorBoundary"; import { motion } from "framer-motion"; +// Wrap ActivityFeed in error boundary to prevent crashes +const ActivityFeed = dynamic(() => import("./components/ActivityFeed").catch(() => ({ default: () => null })), { + ssr: false, + loading: () => null, +}); + export default function Home() { return (
@@ -35,7 +42,9 @@ export default function Home() { }), }} /> - + + +
{/* Spacer to prevent navbar overlap */}