-
Notifications
You must be signed in to change notification settings - Fork 26.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display the stitched error instead of react error #72106
base: canary
Are you sure you want to change the base?
Changes from 5 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use client' | ||
|
||
import Foo from '../foo' | ||
|
||
export default function BrowserOnly() { | ||
return ( | ||
<div> | ||
<Foo /> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use client' | ||
|
||
import dynamic from 'next/dynamic' | ||
|
||
const BrowserOnly = dynamic(() => import('./browser-only'), { | ||
ssr: false, | ||
}) | ||
|
||
export default function Page() { | ||
return <BrowserOnly /> | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { ReactNode } from 'react' | ||
export default function Root({ children }: { children: ReactNode }) { | ||
return ( | ||
<html> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Foo from '../foo' | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<Foo /> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
'use client' | ||
|
||
import Foo from '../foo' | ||
|
||
export default function Page() { | ||
return ( | ||
<div> | ||
<Foo /> | ||
</div> | ||
) | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = { | ||
experimental: { | ||
reactOwnerStack: true, | ||
}, | ||
} | ||
|
||
module.exports = nextConfig |
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where are the assertions on the owner stack in this test? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It doesn't have stacks from user land such as |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,147 @@ | ||||||
import { nextTestSetup } from 'e2e-utils' | ||||||
import { assertHasRedbox, getRedboxSource } from 'next-test-utils' | ||||||
|
||||||
async function getStackFramesContent(browser) { | ||||||
const stackFrameElements = await browser.elementsByCss( | ||||||
'[data-nextjs-call-stack-frame]' | ||||||
) | ||||||
const stackFramesContent = ( | ||||||
await Promise.all( | ||||||
stackFrameElements.map(async (frame) => { | ||||||
const functionNameEl = await frame.$('[data-nextjs-frame-expanded]') | ||||||
const sourceEl = await frame.$('[data-has-source]') | ||||||
const functionName = functionNameEl | ||||||
? await functionNameEl.innerText() | ||||||
: '' | ||||||
const source = sourceEl ? await sourceEl.innerText() : '' | ||||||
|
||||||
if (!functionName) { | ||||||
return '' | ||||||
} | ||||||
return `at ${functionName} (${source})` | ||||||
}) | ||||||
) | ||||||
) | ||||||
.filter(Boolean) | ||||||
.join('\n') | ||||||
|
||||||
return stackFramesContent | ||||||
} | ||||||
|
||||||
describe('app-dir - owner-stack-invalid-element-type', () => { | ||||||
const { next } = nextTestSetup({ | ||||||
files: __dirname, | ||||||
}) | ||||||
|
||||||
it('should catch invalid element from on client-only component', async () => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
I don't see a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's using the |
||||||
const browser = await next.browser('/browser') | ||||||
|
||||||
await assertHasRedbox(browser) | ||||||
const source = await getRedboxSource(browser) | ||||||
|
||||||
const stackFramesContent = await getStackFramesContent(browser) | ||||||
if (process.env.TURBOPACK) { | ||||||
expect(stackFramesContent).toMatchInlineSnapshot( | ||||||
`"at Page (app/browser/page.js (10:10))"` | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the Component name here different between Webpack and Turbopack? Turbopack has |
||||||
) | ||||||
expect(source).toMatchInlineSnapshot(` | ||||||
"app/browser/browser-only.js (8:7) @ BrowserOnly | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is the Component name here different between Turbopack and Webpack? Turbopack has There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's returned from the source map, retrieved by the line number and column number. There might be some inconsistence between two that we need to tackle later with sourcemap. |
||||||
|
||||||
6 | return ( | ||||||
7 | <div> | ||||||
> 8 | <Foo /> | ||||||
| ^ | ||||||
9 | </div> | ||||||
10 | ) | ||||||
11 | }" | ||||||
`) | ||||||
} else { | ||||||
expect(stackFramesContent).toMatchInlineSnapshot( | ||||||
`"at BrowserOnly (app/browser/page.js (10:11))"` | ||||||
) | ||||||
expect(source).toMatchInlineSnapshot(` | ||||||
"app/browser/browser-only.js (8:8) @ Foo | ||||||
|
||||||
6 | return ( | ||||||
7 | <div> | ||||||
> 8 | <Foo /> | ||||||
| ^ | ||||||
9 | </div> | ||||||
10 | ) | ||||||
11 | }" | ||||||
`) | ||||||
} | ||||||
}) | ||||||
|
||||||
it('should catch invalid element from on rsc component', async () => { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
const browser = await next.browser('/rsc') | ||||||
|
||||||
await assertHasRedbox(browser) | ||||||
const stackFramesContent = await getStackFramesContent(browser) | ||||||
const source = await getRedboxSource(browser) | ||||||
|
||||||
if (process.env.TURBOPACK) { | ||||||
expect(stackFramesContent).toMatchInlineSnapshot(`""`) | ||||||
expect(source).toMatchInlineSnapshot(` | ||||||
"app/rsc/page.js (6:7) @ Page | ||||||
|
||||||
4 | return ( | ||||||
5 | <div> | ||||||
> 6 | <Foo /> | ||||||
| ^ | ||||||
7 | </div> | ||||||
8 | ) | ||||||
9 | }" | ||||||
`) | ||||||
} else { | ||||||
expect(stackFramesContent).toMatchInlineSnapshot(`""`) | ||||||
expect(source).toMatchInlineSnapshot(` | ||||||
"app/rsc/page.js (6:8) @ Foo | ||||||
|
||||||
4 | return ( | ||||||
5 | <div> | ||||||
> 6 | <Foo /> | ||||||
| ^ | ||||||
7 | </div> | ||||||
8 | ) | ||||||
9 | }" | ||||||
`) | ||||||
} | ||||||
}) | ||||||
|
||||||
it('should catch invalid element from on ssr client component', async () => { | ||||||
const browser = await next.browser('/ssr') | ||||||
|
||||||
await assertHasRedbox(browser) | ||||||
|
||||||
const stackFramesContent = await getStackFramesContent(browser) | ||||||
const source = await getRedboxSource(browser) | ||||||
if (process.env.TURBOPACK) { | ||||||
expect(stackFramesContent).toMatchInlineSnapshot(`""`) | ||||||
expect(source).toMatchInlineSnapshot(` | ||||||
"app/ssr/page.js (8:7) @ Page | ||||||
|
||||||
6 | return ( | ||||||
7 | <div> | ||||||
> 8 | <Foo /> | ||||||
| ^ | ||||||
9 | </div> | ||||||
10 | ) | ||||||
11 | }" | ||||||
`) | ||||||
} else { | ||||||
expect(stackFramesContent).toMatchInlineSnapshot(`""`) | ||||||
expect(source).toMatchInlineSnapshot(` | ||||||
"app/ssr/page.js (8:8) @ Foo | ||||||
|
||||||
6 | return ( | ||||||
7 | <div> | ||||||
> 8 | <Foo /> | ||||||
| ^ | ||||||
9 | </div> | ||||||
10 | ) | ||||||
11 | }" | ||||||
`) | ||||||
} | ||||||
}) | ||||||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not used anymore, I didn't figure out last time how to get rid of this. Some tests were failing when I replace
[reactError]
withstate.errors
.This time I found that it's the issue with not reporting
error.cause
inonRecoverableError
, otherwise it's erroring with"There was an error during concurrent rendering but React was able to recover by instead synchronously rendering the entire root."
. The critical change is inonRecoverableError