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

Update error message for invalid return value from getStaticPaths #10580

Merged
merged 2 commits into from Feb 19, 2020
Merged
Changes from 1 commit
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
12 changes: 9 additions & 3 deletions packages/next/build/utils.ts
Expand Up @@ -562,9 +562,15 @@ export async function isPageStatic(

const staticPathsResult = await (mod.unstable_getStaticPaths as Unstable_getStaticPaths)()

if (!staticPathsResult || typeof staticPathsResult !== 'object') {
const expectedReturnVal = `Expected: { paths: [] }`

if (
!staticPathsResult ||
typeof staticPathsResult !== 'object' ||
Array.isArray(staticPathsResult)
) {
throw new Error(
`Invalid value returned from unstable_getStaticPaths in ${page}. Received ${typeof staticPathsResult} Expected: { paths: [] }`
`Invalid value returned from unstable_getStaticPaths in ${page}. Received ${typeof staticPathsResult} ${expectedReturnVal}`
)
}

Expand All @@ -576,7 +582,7 @@ export async function isPageStatic(
throw new Error(
`Extra keys returned from unstable_getStaticPaths in ${page} (${invalidStaticPathKeys.join(
', '
)}) The only field allowed currently is \`paths\``
)}) ${expectedReturnVal}`
)
}

Expand Down