Skip to content

Commit

Permalink
Add err.sh for getStaticProps error (#10619)
Browse files Browse the repository at this point in the history
* Add err.sh for getStaticProps error

* Prettify error

Co-authored-by: Joe Haddad <timer150@gmail.com>
  • Loading branch information
ijjk and Timer committed Feb 21, 2020
1 parent b329f6a commit 9507173
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 4 deletions.
17 changes: 17 additions & 0 deletions errors/invalid-getstaticprops-value.md
@@ -0,0 +1,17 @@
# Invalid unstable_getStaticProps Return Value

#### Why This Error Occurred

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

#### Possible Ways to Fix It

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

```js
export async function unstable_getStaticProps() {
return {
props: { [key: string]: any }
}
}
```
2 changes: 1 addition & 1 deletion packages/next/cli/next-build.ts
Expand Up @@ -45,7 +45,7 @@ const nextBuild: cliCommand = argv => {
build(dir)
.then(() => process.exit(0))
.catch(err => {
// tslint:disable-next-line
console.error('')
console.error('> Build error occurred')
printAndExit(err)
})
Expand Down
4 changes: 2 additions & 2 deletions packages/next/export/worker.js
Expand Up @@ -264,8 +264,8 @@ export default async function({
return results
} catch (error) {
console.error(
`\nError occurred prerendering page "${path}" https://err.sh/zeit/next.js/prerender-error:`,
error
`\nError occurred prerendering page "${path}" https://err.sh/next.js/prerender-error:\n` +
error
)
return { ...results, error: true }
}
Expand Down
3 changes: 2 additions & 1 deletion packages/next/next-server/server/render.tsx
Expand Up @@ -246,7 +246,8 @@ const invalidKeysMsg = (methodName: string, invalidKeys: string[]) => {
return (
`Additional keys were returned from \`${methodName}\`. Properties intended for your component must be nested under the \`props\` key, e.g.:` +
`\n\n\treturn { props: { title: 'My Title', content: '...' } }` +
`\n\nKeys that need to be moved: ${invalidKeys.join(', ')}.`
`\n\nKeys that need to be moved: ${invalidKeys.join(', ')}.` +
`\nRead more: https://err.sh/next.js/invalid-getstaticprops-value`
)
}

Expand Down

0 comments on commit 9507173

Please sign in to comment.