diff --git a/packages/next/client/on-recoverable-error.ts b/packages/next/client/on-recoverable-error.ts index 0a1d7d0f789aa..932d3f9e08588 100644 --- a/packages/next/client/on-recoverable-error.ts +++ b/packages/next/client/on-recoverable-error.ts @@ -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 = @@ -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) } diff --git a/test/development/basic/next-dynamic.test.ts b/test/development/basic/next-dynamic.test.ts index 77b5a6ff76050..7155120781cdb 100644 --- a/test/development/basic/next-dynamic.test.ts +++ b/test/development/basic/next-dynamic.test.ts @@ -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', () => { @@ -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()