Skip to content

Commit

Permalink
update turbopack snpashots
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Oct 22, 2024
1 parent 3b15866 commit 9a4c20b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import React from 'react'
import isError from '../../../../../lib/is-error'

const captureOwnerStack = process.env.__NEXT_REACT_OWNER_STACK
? (React as any).captureOwnerStack
: () => ''
const captureOwnerStack = (React as any).captureOwnerStack || (() => '')

const REACT_ERROR_STACK_BOTTOM_FRAME = 'react-stack-bottom-frame'
const REACT_ERROR_STACK_BOTTOM_FRAME_REGEX = new RegExp(
Expand Down
4 changes: 0 additions & 4 deletions packages/next/src/client/react-client-callbacks/app-router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export const onCaughtError: HydrationOptions['onCaughtError'] = (
err,
errorInfo
) => {

// Skip certain custom errors which are not expected to be reported on client
if (isBailoutToCSRError(err) || isNextRouterError(err)) return

Expand Down Expand Up @@ -64,14 +63,11 @@ export const onUncaughtError: HydrationOptions['onUncaughtError'] = (
err,
errorInfo
) => {
console.log('onUncaughtError', err, errorInfo)
// Skip certain custom errors which are not expected to be reported on client
if (isBailoutToCSRError(err) || isNextRouterError(err)) return

const stitchedError = getReactStitchedError(err)

console.log('stitchedError', stitchedError)

if (process.env.NODE_ENV === 'development') {
const componentThatErroredFrame = errorInfo?.componentStack?.split('\n')[1]

Expand Down
25 changes: 20 additions & 5 deletions test/development/app-dir/stitching-errors/stitching-errors.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { nextTestSetup } from 'e2e-utils'
import { assertHasRedbox, assertNoRedbox } from 'next-test-utils'
import {
assertHasRedbox,
assertNoRedbox,
waitForAndOpenRuntimeError,
} from 'next-test-utils'

// TODO: parse the location and assert them in the future
// Remove the location `()` part in every line of stack trace;
Expand Down Expand Up @@ -52,8 +56,8 @@ describe('stitching errors', () => {
const stackFramesContent = await getStackFramesContent(browser)
if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(`
"useErrorHook @ app/browser/uncaught/page.js
Page @ app/browser/uncaught/page.js"
"at useErrorHook (app/browser/uncaught/page.js (10:3))
at Page (app/browser/uncaught/page.js (14:3))"
`)
} else {
expect(stackFramesContent).toMatchInlineSnapshot(`
Expand Down Expand Up @@ -118,6 +122,17 @@ describe('stitching errors', () => {
return log.message.includes('Error: browser error')
}).message

await waitForAndOpenRuntimeError(browser)

const stackFramesContent = await getStackFramesContent(browser)

expect(stackFramesContent).toMatchInlineSnapshot(`
"at useErrorHook (app/browser/caught/page.js (39:3))
at Thrower (app/browser/caught/page.js (29:3))
at Inner (app/browser/caught/page.js (23:7))
at Page (app/browser/caught/page.js (43:10))"
`)

expect(normalizeStackTrace(errorLog)).toMatchInlineSnapshot(`
"Error: browser error
at useThrowError
Expand Down Expand Up @@ -146,8 +161,8 @@ describe('stitching errors', () => {
const stackFramesContent = await getStackFramesContent(browser)
if (process.env.TURBOPACK) {
expect(stackFramesContent).toMatchInlineSnapshot(`
"useErrorHook @ app/ssr/page.js
Page @ app/ssr/page.js"
"at useErrorHook (app/ssr/page.js (8:3))
at Page (app/ssr/page.js (12:3))"
`)
} else {
expect(stackFramesContent).toMatchInlineSnapshot(`
Expand Down

0 comments on commit 9a4c20b

Please sign in to comment.