Skip to content

Commit

Permalink
Add err.sh for invalid getStaticPaths return value (#10605)
Browse files Browse the repository at this point in the history
* Add err.sh for invalid getStaticPaths return value

* Update error link

* Apply suggestions from code review

Co-authored-by: Tim Neutkens <tim@timneutkens.nl>
  • Loading branch information
ijjk and timneutkens committed Feb 20, 2020
1 parent 61025b8 commit db445db
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
18 changes: 18 additions & 0 deletions errors/invalid-getstaticpaths-value.md
@@ -0,0 +1,18 @@
# Invalid unstable_getStaticPaths Return Value

#### Why This Error Occurred

In one of the page's `unstable_getStaticPaths` the return value had the incorrect shape.

#### Possible Ways to Fix It

Make sure to return the following shape from `unstable_getStaticPaths`:

```js
export async function unstable_getStaticProps() {
return {
paths: Array<string | { params: { [key: string]: string } }>
}
}
```

4 changes: 3 additions & 1 deletion packages/next/build/utils.ts
Expand Up @@ -562,7 +562,9 @@ export async function isPageStatic(

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

const expectedReturnVal = `Expected: { paths: [] }`
const expectedReturnVal =
`Expected: { paths: [] }\n` +
`See here for more info: https://err.sh/zeit/next.js/invalid-getstaticpaths-value`

if (
!staticPathsResult ||
Expand Down

0 comments on commit db445db

Please sign in to comment.