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

Add warning for edge with force-static #50182

Merged
merged 2 commits into from
May 22, 2023
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
9 changes: 8 additions & 1 deletion packages/next/src/build/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down
6 changes: 6 additions & 0 deletions test/e2e/app-dir/app-static/app-static.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -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(() =>
Expand Down