Skip to content

Commit

Permalink
Only check startsWith if digest exists
Browse files Browse the repository at this point in the history
  • Loading branch information
timneutkens committed Sep 26, 2022
1 parent 67f93a7 commit ad0d33f
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/next/client/components/layout-router.client.tsx
Expand Up @@ -309,7 +309,7 @@ class RedirectErrorBoundary extends React.Component<
}

static getDerivedStateFromError(error: any) {
if (error.digest.startsWith('NEXT_REDIRECT')) {
if (error.digest?.startsWith('NEXT_REDIRECT')) {
const url = error.digest.split(';')[1]
return { redirect: url }
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/export/worker.ts
Expand Up @@ -421,7 +421,7 @@ export default async function exportPage({
if (
err.digest !== DYNAMIC_ERROR_CODE &&
err.digest !== NOT_FOUND_ERROR_CODE &&
!err.digest.startsWith(REDIRECT_ERROR_CODE)
!err.digest?.startsWith(REDIRECT_ERROR_CODE)
) {
throw err
}
Expand Down
2 changes: 1 addition & 1 deletion packages/next/server/app-render.tsx
Expand Up @@ -175,7 +175,7 @@ function createErrorHandler(
// TODO-APP: Handle redirect throw
err.digest !== DYNAMIC_ERROR_CODE &&
err.digest !== NOT_FOUND_ERROR_CODE &&
!err.digest.startsWith(REDIRECT_ERROR_CODE)
!err.digest?.startsWith(REDIRECT_ERROR_CODE)
) {
// Used for debugging error source
// console.error(_source, err)
Expand Down

0 comments on commit ad0d33f

Please sign in to comment.