diff --git a/packages/next/src/build/utils.ts b/packages/next/src/build/utils.ts index ee8438ca6179f..16b7dd57fa708 100644 --- a/packages/next/src/build/utils.ts +++ b/packages/next/src/build/utils.ts @@ -1384,8 +1384,9 @@ export async function isPageStatic({ let prerenderFallback: boolean | 'blocking' | undefined let appConfig: AppConfig = {} let isClientComponent: boolean = false + const pathIsEdgeRuntime = isEdgeRuntime(pageRuntime) - if (isEdgeRuntime(pageRuntime)) { + if (pathIsEdgeRuntime) { const runtime = await getRuntimeContext({ paths: edgeInfo.files.map((file: string) => path.join(distDir, file)), env: edgeInfo.env, @@ -1503,6 +1504,12 @@ export async function isPageStatic({ {} ) + if (appConfig.dynamic === 'force-static' && pathIsEdgeRuntime) { + Log.warn( + `Page "${page}" is using runtime = 'edge' which is currently incompatible with dynamic = 'force-static'. Please remove either "runtime" or "force-static" for correct behavior` + ) + } + if (appConfig.dynamic === 'force-dynamic') { appConfig.revalidate = 0 } diff --git a/test/e2e/app-dir/app-static/app-static.test.ts b/test/e2e/app-dir/app-static/app-static.test.ts index dd912bcdb166b..7bfb74d7d18e7 100644 --- a/test/e2e/app-dir/app-static/app-static.test.ts +++ b/test/e2e/app-dir/app-static/app-static.test.ts @@ -1270,6 +1270,12 @@ createNextDescribe( expect($2('#page-data').text()).toBe(pageData) return 'success' }, 'success') + + if (isNextStart) { + expect(next.cliOutput).toContain( + `Page "/variable-revalidate-edge/revalidate-3" is using runtime = 'edge' which is currently incompatible with dynamic = 'force-static'. Please remove either "runtime" or "force-static" for correct behavior` + ) + } }) it('should honor fetch cache correctly (edge)', async () => { diff --git a/test/e2e/app-dir/app-static/app/variable-revalidate-edge/revalidate-3/page.js b/test/e2e/app-dir/app-static/app/variable-revalidate-edge/revalidate-3/page.js index 4c5af885392e9..e78de6628c86e 100644 --- a/test/e2e/app-dir/app-static/app/variable-revalidate-edge/revalidate-3/page.js +++ b/test/e2e/app-dir/app-static/app/variable-revalidate-edge/revalidate-3/page.js @@ -1,6 +1,7 @@ import { cache, use } from 'react' export const runtime = 'experimental-edge' +export const dynamic = 'force-static' export default function Page() { const getData = cache(() =>