Missing Error Boundary
Route layouts with no error.tsx beside them
infoReliability
missing-error-boundaryWhy this matters
A layout with no error.tsx next to it has no boundary of its own. A runtime error anywhere in that segment climbs to the nearest parent boundary, or to none, and takes the whole section of the app with it.
Example
app/dashboard/layout.tsx// There is no app/dashboard/error.tsx next to this layout
export default function DashboardLayout({
children,
}: {
children: React.ReactNode;
}) {
return <section>{children}</section>;
}app/dashboard/error.tsx"use client";
export default function Error({
error,
reset,
}: {
error: Error;
reset: () => void;
}) {
return (
<div>
<h2>Something went wrong</h2>
<button onClick={reset}>Try again</button>
</div>
);
}How to fix
Add an error.tsx next to every nested layout.tsx. Give it a retry button that calls reset().
Reference
- In the output
- Findings carry
"ruleId": "missing-error-boundary"in--jsonand the same id in SARIF and in the terminal. - Silence one line
// prodlint-disable-next-line missing-error-boundary- Silence a whole file
// prodlint-disable missing-error-boundaryat the top of the file- How it works
- Matches text patterns. Source on GitHub