Skip to content

Commit

Permalink
fix rsc payload
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Sep 6, 2024
1 parent fd73701 commit 616fd42
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions packages/next/src/server/app-render/app-render.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,11 @@ async function generateFlight(
flightRouterState,
isFirst: true,
// For flight, render metadata inside leaf page
rscPayloadHead: <MetadataTree key={requestId} />,
// NOTE: in 14.2, fragment doesn't work well with React, using array instead
rscPayloadHead: [
<MetadataTree key={requestId} />,
<NonIndex key="noindex" ctx={ctx} />,
],
injectedCSS: new Set(),
injectedJS: new Set(),
injectedFontPreloadTags: new Set(),
Expand Down Expand Up @@ -526,11 +530,11 @@ async function ReactServerError({
const head = (
<>
{/* Adding requestId as react key to make metadata remount for each render */}
<NonIndex ctx={ctx} />
<MetadataTree key={requestId} />
{process.env.NODE_ENV === 'development' && (
<meta name="next-error" content="not-found" />
)}
<NonIndex ctx={ctx} />
</>
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ createNextDescribe(
({ next }) => {
it('should show the index title', async () => {
const browser = await next.browser('/')
expect(browser.elementByCss('title').text()).toBe('Home Layout')
expect(await browser.elementByCss('title').text()).toBe('Home Layout')
})

it('should show target page metadata after navigation', async () => {
Expand All @@ -22,7 +22,7 @@ createNextDescribe(
const browser = await next.browser('/')
await browser.elementByCss('#product-link').click()
await browser.waitForElementByCss('#product-title')
await browser.elementByCss('#back-link').click()
await browser.elementByCss('#home-link').click()
await browser.waitForElementByCss('#home-title')
expect(await browser.elementByCss('title').text()).toBe('Home Layout')
})
Expand Down
3 changes: 2 additions & 1 deletion test/turbopack-build-tests-manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2118,7 +2118,8 @@
"app dir - not-found - basic with default runtime should use the not-found page for non-matching routes",
"app dir - not-found - basic with runtime = edge should escalate notFound to parent layout if no not-found boundary present in current layer",
"app dir - not-found - basic with runtime = edge should match dynamic route not-found boundary correctly",
"app dir - not-found - basic with runtime = edge should use the not-found page for non-matching routes"
"app dir - not-found - basic with runtime = edge should use the not-found page for non-matching routes",
"app dir - not-found - basic should return 404 status code for custom not-found page"
],
"failed": [
"app dir - not-found - basic should include not found client reference manifest in the file trace"
Expand Down

0 comments on commit 616fd42

Please sign in to comment.