Skip to content

Commit

Permalink
Update onCaughtError interceptor
Browse files Browse the repository at this point in the history
Would be nice to do this via onCaughtError but I copying the full impl of `defaultOnCaughtError` seems sketchy.
See https://vercel.slack.com/archives/C04TR3U872A/p1713969391445789 for quick proposal
  • Loading branch information
eps1lon committed Apr 24, 2024
1 parent 7d6640c commit 4275064
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/next/src/client/app-index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,12 @@ 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])) {
// See https://github.com/facebook/react/blob/d50323eb845c5fde0d720cae888bf35dedd05506/packages/react-reconciler/src/ReactFiberErrorLogger.js#L78
if (
process.env.NODE_ENV !== 'production'
? isNextRouterError(args[1])
: isNextRouterError(args[0])
) {
return
}
origConsoleError.apply(window.console, args)
Expand Down

0 comments on commit 4275064

Please sign in to comment.