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

dynamic = 'error' should only throw if page didn't get exported #43377

Merged
merged 3 commits into from Nov 26, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions packages/next/export/worker.ts
Expand Up @@ -328,18 +328,16 @@ export default async function exportPage({
const revalidate = (curRenderOpts as any).revalidate
results.fromBuildExportRevalidate = revalidate

if (isDynamicError) {
throw new Error(
`Page with dynamic = "error" encountered dynamic data method ${path}.`
)
}

if (revalidate !== 0) {
await promises.writeFile(htmlFilepath, html ?? '', 'utf8')
await promises.writeFile(
htmlFilepath.replace(/\.html$/, '.rsc'),
flightData
)
} else if (isDynamicError) {
throw new Error(
`Page with dynamic = "error" encountered dynamic data method ${path}.`
)
}
} catch (err: any) {
if (
Expand Down
8 changes: 8 additions & 0 deletions test/e2e/app-dir/app-static.test.ts
Expand Up @@ -51,6 +51,9 @@ describe('app-dir static/dynamic handling', () => {
'blog/tim.rsc',
'blog/tim/first-post.html',
'blog/tim/first-post.rsc',
'dynamic-error.html',
'dynamic-error.rsc',
'dynamic-error/page.js',
'dynamic-no-gen-params-ssr/[slug]/page.js',
'dynamic-no-gen-params/[slug]/page.js',
'force-static/[slug]/page.js',
Expand Down Expand Up @@ -107,6 +110,11 @@ describe('app-dir static/dynamic handling', () => {
srcRoute: '/blog/[author]/[slug]',
dataRoute: '/blog/tim/first-post.rsc',
},
'/dynamic-error': {
dataRoute: '/dynamic-error.rsc',
initialRevalidateSeconds: false,
srcRoute: '/dynamic-error',
},
'/blog/seb/second-post': {
initialRevalidateSeconds: false,
srcRoute: '/blog/[author]/[slug]',
Expand Down
5 changes: 5 additions & 0 deletions test/e2e/app-dir/app-static/app/dynamic-error/page.js
@@ -0,0 +1,5 @@
export const dynamic = 'error'

export default function Page() {
return <p>Dynamic error</p>
}