Unverified Commit 2a084334 authored by JJ Kasper's avatar JJ Kasper Committed by GitHub

Update error message for invalid return value from getStaticPaths (#10580)

parent 0a5cc30e
...@@ -562,9 +562,15 @@ export async function isPageStatic( ...@@ -562,9 +562,15 @@ export async function isPageStatic(
const staticPathsResult = await (mod.unstable_getStaticPaths as Unstable_getStaticPaths)() 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( 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}`
) )
} }
...@@ -576,7 +582,7 @@ export async function isPageStatic( ...@@ -576,7 +582,7 @@ export async function isPageStatic(
throw new Error( throw new Error(
`Extra keys returned from unstable_getStaticPaths in ${page} (${invalidStaticPathKeys.join( `Extra keys returned from unstable_getStaticPaths in ${page} (${invalidStaticPathKeys.join(
', ' ', '
)}) The only field allowed currently is \`paths\`` )}) ${expectedReturnVal}`
) )
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment