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 2cb4e50 commit c4cb522
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 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,8 @@ 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])) {
// error is the second argument to `console.error`: https://github.com/facebook/react/blob/d50323eb845c5fde0d720cae888bf35dedd05506/packages/react-reconciler/src/ReactFiberErrorLogger.js#L78
if (isNextRouterError(args[1])) {
return
}
origConsoleError.apply(window.console, args)
Expand Down

0 comments on commit c4cb522

Please sign in to comment.