diff --git a/app/layout.tsx b/app/layout.tsx index 5e3355ce9..82ff768f9 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -3,6 +3,7 @@ import { Navbar } from 'components/layout/navbar'; import { WelcomeToast } from 'components/welcome-toast'; import { GeistSans } from 'geist/font/sans'; import { getCart } from 'lib/shopify'; +import type { Cart } from 'lib/shopify/types'; import { ReactNode } from 'react'; import { Toaster } from 'sonner'; import './globals.css'; @@ -27,13 +28,20 @@ export default async function RootLayout({ }: { children: ReactNode; }) { - // Don't await the fetch, pass the Promise to the context provider - const cart = getCart(); + let cartPromise: Promise; + + try { + // Don't await the fetch, pass the Promise to the context provider + cartPromise = getCart(); + } catch (e) { + console.error('Failed to get cart during layout rendering (possibly build time for static page):', e); + cartPromise = Promise.resolve(undefined); + } return ( - +
{children}