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

Fix error message for invalid runtime option in app dir #43900

Merged
merged 1 commit into from
Dec 9, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/next/build/analysis/get-page-static-info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ export async function getPageStaticInfo(params: {
)
} else {
Log.error(
`Provided runtime "${config.runtime}" is not supported. Please leave it empty or choose one of: ${options}`
`Provided runtime "${resolvedRuntime}" is not supported. Please leave it empty or choose one of: ${options}`
)
}
if (!isDev) {
Expand Down
3 changes: 3 additions & 0 deletions test/e2e/switchable-runtime/app/app-invalid-runtime/page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export default function Page() {
return <p>Hello from app</p>
}
28 changes: 28 additions & 0 deletions test/e2e/switchable-runtime/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,34 @@ describe('Switchable runtime', () => {
/Hello from page without errors/
)
})

it('should give proper errors for invalid runtime in app dir', async () => {
// Invalid runtime
await next.patchFile(
'app/app-invalid-runtime/page.js',
`
export default function Page() {
return <p>Hello from app</p>
}
export const runtime = 'invalid-runtime'
`
)
await check(
() => renderViaHTTP(next.url, '/app-invalid-runtime'),
/Hello from app/
)
expect(next.cliOutput).toInclude(
'error - Provided runtime "invalid-runtime" is not supported. Please leave it empty or choose one of:'
)

await next.patchFile(
'app/app-invalid-runtime/page.js',
`
export default function Page() {
return <p>Hello from app</p>
}`
)
})
})
} else {
describe('Switchable runtime (prod)', () => {
Expand Down