Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure thrown errors that are handled by React are associated with the original component not Next.js error boundaries #67861

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/next/src/client/components/not-found-boundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,9 @@ class NotFoundErrorBoundary extends React.Component<
notFoundTriggered: true,
}
}
// Re-throw if error is not for 404
throw error
return {
notFoundTriggered: false,
}
}

static getDerivedStateFromProps(
Expand Down
6 changes: 4 additions & 2 deletions packages/next/src/client/components/redirect-boundary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,10 @@ export class RedirectErrorBoundary extends React.Component<
const redirectType = getRedirectTypeFromError(error)
return { redirect: url, redirectType }
}
// Re-throw if error is not for redirect
throw error
return {
redirect: null,
redirectType: null,
}
}

// Explicit type is needed to avoid the generated `.d.ts` having a wide return type that could be specific the the `@types/react` version.
Expand Down
Loading