Skip to content

Commit

Permalink
skip internal error
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Jul 13, 2023
1 parent fbecaf9 commit 0153534
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ import {
createFlightRouterStateFromLoaderTree,
} from './create-flight-router-state-from-loader-tree'
import { handleAction } from './action-handler'
import { NEXT_DYNAMIC_NO_SSR_CODE } from '../../shared/lib/lazy-dynamic/no-ssr-error'
import {
NEXT_DYNAMIC_NO_SSR_CODE,
isNextDynamicNoSSRError,
} from '../../shared/lib/lazy-dynamic/no-ssr-error'
import { warn } from '../../build/output/log'
import { appendMutableCookies } from '../web/spec-extension/adapters/request-cookies'
import { ComponentsType } from '../../build/webpack/loaders/next-app-loader'
Expand Down Expand Up @@ -1630,7 +1633,10 @@ export async function renderToHTMLOrFlight(
const use404Error = res.statusCode === 404
// When it's in error state but status code is not 200, we should render global-error
const useGlobalError =
res.statusCode === 200 && process.env.NODE_ENV === 'production'
res.statusCode === 200 &&
// skip the built-in error
!isNextDynamicNoSSRError(err) &&
process.env.NODE_ENV === 'production'
const useDefaultError =
(res.statusCode < 400 || res.statusCode === 307) && !useGlobalError

Expand Down
2 changes: 2 additions & 0 deletions packages/next/src/shared/lib/lazy-dynamic/no-ssr-error.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// This has to be a shared module which is shared between client component error boundary and dynamic component

export const NEXT_DYNAMIC_NO_SSR_CODE = 'NEXT_DYNAMIC_NO_SSR_CODE'
export const isNextDynamicNoSSRError = (err: any) =>
err && err.digest === NEXT_DYNAMIC_NO_SSR_CODE

0 comments on commit 0153534

Please sign in to comment.