Skip to content

Commit 31b2e80

Browse files
frano-mclaude
andauthored
fix: move providers inside ErrorBoundary to prevent crash loop (#4783)
* fix: move providers inside ErrorBoundary to prevent crash loop (#4776) Move ExploreStateProvider, DataDictionaryStateProvider, and FileManifestStateProvider inside the ErrorBoundary in _app.tsx. Previously these providers sat above the ErrorBoundary. When a provider crashed (e.g. ExploreStateProvider's reducer throwing on a malformed filter URL param), the error bypassed the ErrorBoundary entirely and bubbled up to Next.js's built-in error handling, which attempted to recover by re-rendering the page — triggering the same crash in an infinite loop. With the providers inside the ErrorBoundary, any error from their reducers, hooks, or child components is caught and rendered as the Error fallback page. The header and footer remain visible (they are intentionally outside the boundary) so the user can still navigate away. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> * fix: revert unintended package.json/lock changes (#4776) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Fran McDade <18710366+frano-m@users.noreply.github.com> Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent dcaeb35 commit 31b2e80

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

pages/_app.tsx

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -95,33 +95,33 @@ function MyApp({ Component, pageProps }: AppPropsWithComponent): JSX.Element {
9595
>
9696
<Header {...header} />
9797
</ThemeProvider>
98-
<ExploreStateProvider entityListType={entityListType}>
99-
<DataDictionaryStateProvider>
100-
<Main>
101-
<ErrorBoundary
102-
fallbackRender={({
103-
error,
104-
reset,
105-
}: {
106-
error: DataExplorerError;
107-
reset: () => void;
108-
}): JSX.Element => (
109-
<Error
110-
errorMessage={error.message}
111-
requestUrlMessage={error.requestUrlMessage}
112-
rootPath={redirectRootToPath}
113-
onReset={reset}
114-
/>
115-
)}
116-
>
98+
<Main>
99+
<ErrorBoundary
100+
fallbackRender={({
101+
error,
102+
reset,
103+
}: {
104+
error: DataExplorerError;
105+
reset: () => void;
106+
}): JSX.Element => (
107+
<Error
108+
errorMessage={error.message}
109+
requestUrlMessage={error.requestUrlMessage}
110+
rootPath={redirectRootToPath}
111+
onReset={reset}
112+
/>
113+
)}
114+
>
115+
<ExploreStateProvider entityListType={entityListType}>
116+
<DataDictionaryStateProvider>
117117
<FileManifestStateProvider>
118118
<Component {...pageProps} />
119119
<Floating {...floating} />
120120
</FileManifestStateProvider>
121-
</ErrorBoundary>
122-
</Main>
123-
</DataDictionaryStateProvider>
124-
</ExploreStateProvider>
121+
</DataDictionaryStateProvider>
122+
</ExploreStateProvider>
123+
</ErrorBoundary>
124+
</Main>
125125
<Footer {...footer} />
126126
</AppLayout>
127127
</LayoutDimensionsProvider>

0 commit comments

Comments
 (0)