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

Also check error.message as digest for recoverable errors in pages #44185

Merged
merged 3 commits into from
Dec 20, 2022
Merged
Show file tree
Hide file tree
Changes from 2 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
6 changes: 4 additions & 2 deletions packages/next/client/on-recoverable-error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { NEXT_DYNAMIC_NO_SSR_CODE } from '../shared/lib/no-ssr-error'

export default function onRecoverableError(err: any) {
export default function onRecoverableError(err: any, errorInfo: any) {
const digest = err.digest || errorInfo.digest

// Using default react onRecoverableError
// x-ref: https://github.com/facebook/react/blob/d4bc16a7d69eb2ea38a88c8ac0b461d5f72cdcab/packages/react-dom/src/client/ReactDOMRoot.js#L83
const defaultOnRecoverableError =
Expand All @@ -13,6 +15,6 @@ export default function onRecoverableError(err: any) {
}

// Skip certain custom errors which are not expected to be reported on client
if (err.digest === NEXT_DYNAMIC_NO_SSR_CODE) return
if (digest === NEXT_DYNAMIC_NO_SSR_CODE) return
defaultOnRecoverableError(err)
}
3 changes: 2 additions & 1 deletion test/development/basic/next-dynamic.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { join } from 'path'
import cheerio from 'cheerio'
import webdriver from 'next-webdriver'
import { createNext, FileRef } from 'e2e-utils'
import { renderViaHTTP, check } from 'next-test-utils'
import { renderViaHTTP, check, hasRedbox } from 'next-test-utils'
import { NextInstance } from 'test/lib/next-modes/base'

describe('basic next/dynamic usage', () => {
Expand Down Expand Up @@ -124,6 +124,7 @@ describe('basic next/dynamic usage', () => {
() => browser.elementByCss('body').text(),
/Hello World 1/
)
expect(await hasRedbox(browser)).toBe(false)
} finally {
if (browser) {
await browser.close()
Expand Down