Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fail on prerendering with dynamic error config (#41707)
This PR adds the ability to fail on pre-rendering for a page configured with `dynamic="error"`
- Loading branch information
1 parent
ceb07ff
commit 95af245
Showing
7 changed files
with
52 additions
and
0 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
3 changes: 3 additions & 0 deletions
3
test/integration/app-dynamic-error/app/dynamic-error/loading.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,3 @@ | ||
export default function Page() { | ||
return <p>loading...</p> | ||
} |
13 changes: 13 additions & 0 deletions
13
test/integration/app-dynamic-error/app/dynamic-error/page.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,13 @@ | ||
import { headers } from 'next/headers' | ||
|
||
export const dynamic = 'error' | ||
|
||
export default function Page() { | ||
headers() | ||
return ( | ||
<> | ||
<p id="page">/dynamic-error</p> | ||
<p id="date">{Date.now()}</p> | ||
</> | ||
) | ||
} |
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,10 @@ | ||
export default function Layout({ children }) { | ||
return ( | ||
<html lang="en"> | ||
<head> | ||
<title>my static blog</title> | ||
</head> | ||
<body>{children}</body> | ||
</html> | ||
) | ||
} |
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 @@ | ||
module.exports = { | ||
experimental: { | ||
appDir: true, | ||
}, | ||
} |
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 { nextBuild } from 'next-test-utils' | ||
import { join } from 'path' | ||
|
||
it('throws an error when prerendering a page with config dynamic error', async () => { | ||
const appDir = join(__dirname, '../../app-dynamic-error') | ||
const { stderr, code } = await nextBuild(appDir, [], { | ||
stderr: true, | ||
stdout: true, | ||
}) | ||
expect(stderr).toContain('Error occurred prerendering page "/dynamic-error"') | ||
expect(code).toBe(1) | ||
}) |