Skip to content

Commit

Permalink
log origin error
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Oct 27, 2024
1 parent 0b525a1 commit 99f7151
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/next/src/client/react-client-callbacks/app-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export const onCaughtError: HydrationOptions['onCaughtError'] = (
}

// Log and report the error with location but without modifying the error stack
originConsoleError('%o\n\n%s', stitchedError, errorLocation)
originConsoleError('%o\n\n%s', err, errorLocation)

handleClientError(stitchedError, [])
} else {
Expand Down Expand Up @@ -85,7 +85,7 @@ export const onUncaughtError: HydrationOptions['onUncaughtError'] = (
}

// Log and report the error with location but without modifying the error stack
originConsoleError('%o\n\n%s', stitchedError, errorLocation)
originConsoleError('%o\n\n%s', err, errorLocation)
reportGlobalError(stitchedError)
} else {
reportGlobalError(err)
Expand Down
62 changes: 44 additions & 18 deletions test/development/app-dir/owner-stack/owner-stack.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,17 @@ describe('app-dir - owner-stack', () => {
at useThrowError
at useErrorHook
at Page
at NotFoundBoundary
at DevRootNotFoundBoundary
at Router
at AppRouter
at ServerRoot The above error occurred in the <Page> component. It was handled by the <ReactDevOverlay> error boundary."
at react-stack-bottom-frame
at renderWithHooks
at updateFunctionComponent
at beginWork
at runWithFiberInDEV
at performUnitOfWork
at workLoopSync
at renderRootSync
at performWorkOnRoot
at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <ReactDevOverlay> error boundary."
`)
} else {
expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(`
Expand All @@ -92,11 +98,17 @@ describe('app-dir - owner-stack', () => {
at useThrowError
at useErrorHook
at Page
at NotFoundBoundary
at DevRootNotFoundBoundary
at Router
at AppRouter
at ServerRoot The above error occurred in the <Page> component. It was handled by the <ReactDevOverlay> error boundary."
at react-stack-bottom-frame
at renderWithHooks
at updateFunctionComponent
at beginWork
at runWithFiberInDEV
at performUnitOfWork
at workLoopSync
at renderRootSync
at performWorkOnRoot
at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <ReactDevOverlay> error boundary."
`)
}
})
Expand Down Expand Up @@ -137,9 +149,17 @@ describe('app-dir - owner-stack', () => {
at useThrowError
at useErrorHook
at Thrower
at Inner
at Page
at ClientPageRoot The above error occurred in the <Thrower> component. It was handled by the <MyErrorBoundary> error boundary."
at react-stack-bottom-frame
at renderWithHooks
at updateFunctionComponent
at beginWork
at runWithFiberInDEV
at performUnitOfWork
at workLoopSync
at renderRootSync
at performWorkOnRoot
at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Thrower> component. It was handled by the <MyErrorBoundary> error boundary."
`)
})

Expand Down Expand Up @@ -172,11 +192,17 @@ describe('app-dir - owner-stack', () => {
at useThrowError
at useErrorHook
at Page
at NotFoundBoundary
at DevRootNotFoundBoundary
at Router
at AppRouter
at ServerRoot The above error occurred in the <Page> component. It was handled by the <ReactDevOverlay> error boundary."
at react-stack-bottom-frame
at renderWithHooks
at updateFunctionComponent
at beginWork
at runWithFiberInDEV
at performUnitOfWork
at workLoopSync
at renderRootSync
at performWorkOnRoot
at performWorkOnRootViaSchedulerTask
at MessagePort.performWorkUntilDeadline The above error occurred in the <Page> component. It was handled by the <ReactDevOverlay> error boundary."
`)
})

Expand Down

0 comments on commit 99f7151

Please sign in to comment.