-
Notifications
You must be signed in to change notification settings - Fork 27.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[metadata] disable streaming metadata for ppr deployment
- Loading branch information
Showing
9 changed files
with
119 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
test/production/app-dir/ppr-disable-streaming-metadata/app/dynamic/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Suspense } from 'react' | ||
|
||
export default function Root({ children }) { | ||
return <Suspense fallback={<p>Loading...</p>}>{children}</Suspense> | ||
} |
12 changes: 12 additions & 0 deletions
12
test/production/app-dir/ppr-disable-streaming-metadata/app/dynamic/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { connection } from 'next/server' | ||
|
||
export default async function Page() { | ||
return <p>hello world</p> | ||
} | ||
|
||
// Dynamic metadata | ||
export async function generateMetadata() { | ||
await connection() | ||
await new Promise((resolve) => setTimeout(resolve, 1000)) | ||
return { title: 'dynamic-title' } | ||
} |
16 changes: 16 additions & 0 deletions
16
test/production/app-dir/ppr-disable-streaming-metadata/app/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { ReactNode } from 'react' | ||
import Link from 'next/link' | ||
|
||
export default function Root({ children }: { children: ReactNode }) { | ||
return ( | ||
<html> | ||
<body> | ||
<nav> | ||
<Link href="/ppr">ppr</Link> | ||
<Link href="/dynamic">dynamic</Link> | ||
</nav> | ||
{children} | ||
</body> | ||
</html> | ||
) | ||
} |
5 changes: 5 additions & 0 deletions
5
test/production/app-dir/ppr-disable-streaming-metadata/app/ppr/layout.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { Suspense } from 'react' | ||
|
||
export default function Root({ children }) { | ||
return <Suspense fallback={<p>Loading...</p>}>{children}</Suspense> | ||
} |
13 changes: 13 additions & 0 deletions
13
test/production/app-dir/ppr-disable-streaming-metadata/app/ppr/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { connection } from 'next/server' | ||
|
||
export default async function Page() { | ||
await connection() | ||
return <p>ppr</p> | ||
} | ||
|
||
export async function generateMetadata() { | ||
await connection() | ||
return { title: 'ppr-title' } | ||
} | ||
|
||
export const experimental_ppr = true |
11 changes: 11 additions & 0 deletions
11
test/production/app-dir/ppr-disable-streaming-metadata/next.config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* @type {import('next').NextConfig} | ||
*/ | ||
const nextConfig = { | ||
experimental: { | ||
ppr: 'incremental', | ||
streamingMetadata: true, | ||
}, | ||
} | ||
|
||
module.exports = nextConfig |
31 changes: 31 additions & 0 deletions
31
.../production/app-dir/ppr-disable-streaming-metadata/ppr-disable-streaming-metadata.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { nextTestSetup } from 'e2e-utils' | ||
|
||
describe('ppr-disable-streaming-metadata', () => { | ||
const { next } = nextTestSetup({ | ||
files: __dirname, | ||
skipDeployment: true, | ||
env: { | ||
// Using VERCEL=1 to simulate deployment on Vercel | ||
VERCEL: '1', | ||
}, | ||
}) | ||
|
||
it('should enable streaming metadata for suspenseful dynamic metadata page', async () => { | ||
const $ = await next.render$('/dynamic') | ||
expect($('body title').text()).toBe('dynamic-title') | ||
|
||
const browser = await next.browser('/dynamic') | ||
const title = await browser.eval(() => document.title) | ||
expect(title).toBe('dynamic-title') | ||
}) | ||
|
||
it('should not enable streaming metadata for ppr page', async () => { | ||
const $ = await next.render$('/ppr') | ||
// Dynamic metadata will be suspended and not rendered in default PPR mode | ||
expect($('title').length).toBe(0) | ||
|
||
const browser = await next.browser('/ppr') | ||
const title = await browser.eval(() => document.title) | ||
expect(title).toBe('ppr-title') | ||
}) | ||
}) |