fix(routing): give every lazy page its own ErrorBoundary

A render error in any route used to bubble all the way up to the single
page-level boundary at AppWithNavigator, replacing the entire shell
(sidebar, header, blocking overlays) with the contained error UI — even
if only one sub-page was broken.

Embed an ErrorBoundary inside LazyPage so the smallest meaningful unit
(a route's lazy chunk + its rendered tree) is the boundary scope. Shell
chrome stays alive, the user can navigate elsewhere, and chunk-load
failures still get the lazyWithRetry reload path because the boundary
sits outside Suspense.
This commit is contained in:
c0mrade
2026-05-26 14:01:56 +03:00
parent 23e4e9b4d1
commit 87e2e82136

View File

@@ -200,9 +200,16 @@ function AdminRoute({ children }: { children: React.ReactNode }) {
return <Layout>{children}</Layout>;
}
// Suspense wrapper for lazy components
// Suspense + error boundary wrapper for lazy routes. The boundary lives
// OUTSIDE Suspense so chunk-load failures (caught by lazyWithRetry's reload
// path) and render-time exceptions both surface in the page-level fallback
// instead of crashing the entire shell via the top-level boundary.
function LazyPage({ children }: { children: React.ReactNode }) {
return <Suspense fallback={<PageLoader variant="dark" />}>{children}</Suspense>;
return (
<ErrorBoundary level="page">
<Suspense fallback={<PageLoader variant="dark" />}>{children}</Suspense>
</ErrorBoundary>
);
}
function BlockingOverlay() {