mirror of
https://github.com/vercel/commerce.git
synced 2025-06-17 20:51:21 +00:00
The prerendering of the `/_not-found` page was failing due to an error in the Server Components render, specifically when the `RootLayout` attempted to fetch cart data using `getCart()`. The `getCart()` function uses `cookies()`, which is not available or reliable during the static prerendering of error pages. This commit modifies `app/layout.tsx` to wrap the `getCart()` call in a `try...catch` block. If an error occurs during this call (e.g., during build-time rendering of `_not-found.tsx`), it now logs the error and defaults to a `Promise.resolve(undefined)` for the cart state. The `CartProvider` and related components are already designed to handle an undefined cart, ensuring that your application remains stable and the build process can complete successfully for static pages like `_not-found`.