From 99f71518dd9fd083de49bb4e29b56955e05af921 Mon Sep 17 00:00:00 2001 From: Jiachi Liu Date: Sun, 27 Oct 2024 20:40:10 +0100 Subject: [PATCH] log origin error --- .../react-client-callbacks/app-router.ts | 4 +- .../app-dir/owner-stack/owner-stack.test.ts | 62 +++++++++++++------ 2 files changed, 46 insertions(+), 20 deletions(-) diff --git a/packages/next/src/client/react-client-callbacks/app-router.ts b/packages/next/src/client/react-client-callbacks/app-router.ts index f74de48b57af7..099769656ad14 100644 --- a/packages/next/src/client/react-client-callbacks/app-router.ts +++ b/packages/next/src/client/react-client-callbacks/app-router.ts @@ -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 { @@ -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) diff --git a/test/development/app-dir/owner-stack/owner-stack.test.ts b/test/development/app-dir/owner-stack/owner-stack.test.ts index 89970ed5eaa0c..1257740989d9d 100644 --- a/test/development/app-dir/owner-stack/owner-stack.test.ts +++ b/test/development/app-dir/owner-stack/owner-stack.test.ts @@ -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 component. It was handled by the 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 component. It was handled by the error boundary." `) } else { expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(` @@ -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 component. It was handled by the 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 component. It was handled by the error boundary." `) } }) @@ -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 component. It was handled by the 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 component. It was handled by the error boundary." `) }) @@ -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 component. It was handled by the 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 component. It was handled by the error boundary." `) })