Skip to content
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

[metadata] remove the duplicate metadata in the error boundary #76791

Merged
merged 6 commits into from
Mar 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions packages/next/src/server/app-render/create-component-tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -411,23 +411,20 @@ async function createComponentTreeInternal({
const notFoundElement = NotFound ? (
<>
<NotFound />
{metadata}
{notFoundStyles}
</>
) : undefined

const forbiddenElement = Forbidden ? (
<>
<Forbidden />
{metadata}
{forbiddenStyles}
</>
) : undefined

const unauthorizedElement = Unauthorized ? (
<>
<Unauthorized />
{metadata}
{unauthorizedStyles}
</>
) : undefined
Expand Down Expand Up @@ -858,7 +855,6 @@ async function createComponentTreeInternal({
{notFoundStyles}
<NotFound />
</SegmentComponent>
{metadata}
</>
) : undefined
}
Expand Down
6 changes: 5 additions & 1 deletion test/e2e/app-dir/parallel-routes-not-found/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ export default function Layout({
slot: React.ReactNode
}) {
return (
<html>
<html lang="en" className="layout">
<body>
{children}
{slot}
</body>
</html>
)
}

export const metadata = {
title: 'layout title',
}
4 changes: 1 addition & 3 deletions test/e2e/app-dir/parallel-routes-not-found/next.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
pageExtensions: ['tsx', 'ts'],
}
const nextConfig = {}

module.exports = nextConfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { nextTestSetup } from 'e2e-utils'

const isPPR = process.env.__NEXT_EXPERIMENTAL_PPR === 'true'

describe('parallel-routes-and-interception', () => {
const { next, skipped } = nextTestSetup({
const { next, isNextDev, skipped } = nextTestSetup({
files: __dirname,
// TODO: remove after deployment handling is updated
skipDeployment: true,
Expand All @@ -21,5 +23,28 @@ describe('parallel-routes-and-interception', () => {

// we also check that the #children-slot id is not present
expect(await browser.hasElementByCssSelector('#children-slot')).toBe(false)

if (isPPR && !isNextDev) {
let $ = await next.render$('/')
expect($('title').text()).toBe('')

$ = await next.render$('/', null, {
headers: {
'User-Agent': 'Discordbot',
},
})
expect($('title').text()).toBe('layout title')
} else {
const $ = await next.render$('/')
expect($('title').text()).toBe('layout title')
}
})

it('should render the title once for the non-existed route', async () => {
const browser = await next.browser('/non-existed')
const titles = await browser.elementsByCss('title')

// FIXME: (metadata), the title should only be rendered once and using the not-found title
expect(titles).toHaveLength(3)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have another duplicated metadata issue which is not tight to this change, more like existing issue. But we can tackle that later

})
})
2 changes: 1 addition & 1 deletion test/e2e/app-dir/parallel-routes-not-found/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
"target": "ES2017"
},
"include": ["next-env.d.ts", ".next/types/**/*.ts", "**/*.ts", "**/*.tsx"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "**/*.test.ts", "**/*.test.tsx"]
}
Loading