diff --git a/packages/next/src/client/app-index.tsx b/packages/next/src/client/app-index.tsx index e4c9d7632d7b8..f51ee2536c873 100644 --- a/packages/next/src/client/app-index.tsx +++ b/packages/next/src/client/app-index.tsx @@ -19,7 +19,10 @@ import { HMR_ACTIONS_SENT_TO_BROWSER } from '../server/dev/hot-reloader-types' // Since React doesn't call onerror for errors caught in error boundaries. const origConsoleError = window.console.error window.console.error = (...args) => { - if (isNextRouterError(args[0])) { + // in dev, the actual error is the second argument. + const error = process.env.NODE_ENV === 'development' ? args[1] : args[0] + + if (isNextRouterError(error)) { return } origConsoleError.apply(window.console, args) diff --git a/test/development/acceptance-app/hydration-error.test.ts b/test/development/acceptance-app/hydration-error.test.ts index 26b8e9d0cc4b1..1414b2ceb394a 100644 --- a/test/development/acceptance-app/hydration-error.test.ts +++ b/test/development/acceptance-app/hydration-error.test.ts @@ -570,7 +570,7 @@ describe('Error overlay for hydration errors', () => { const warning = await session.getRedboxDescriptionWarning() expect(warning).toContain( - 'In HTML,