Unverified Commit aef927d5 authored by Joe Haddad's avatar Joe Haddad Committed by GitHub

Disallow iSSG revalidation period of zero (#9280)

* Disallow iSSG revalidation period of zero

* Fix revalidation period in test
parent 7c80febc
...@@ -427,9 +427,9 @@ export async function renderToHTML( ...@@ -427,9 +427,9 @@ export async function renderToHTML(
if (invalidKeys.length) { if (invalidKeys.length) {
throw new Error( throw new Error(
`Additional keys were returned from \`getStaticProps\`. 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 moved: ${invalidKeys.join( `Additional keys were returned from \`getStaticProps\`. 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 moved: ${invalidKeys.join(', ')}.
` `
) )
} }
...@@ -442,12 +442,13 @@ export async function renderToHTML( ...@@ -442,12 +442,13 @@ export async function renderToHTML(
}', cannot be used.` + }', cannot be used.` +
`\nTry changing the value to '${Math.ceil( `\nTry changing the value to '${Math.ceil(
data.revalidate data.revalidate
)}' or using \`Math.round()\` if you're computing the value.` )}' or using \`Math.ceil()\` if you're computing the value.`
) )
} else if (data.revalidate < 0) { } else if (data.revalidate <= 0) {
throw new Error( throw new Error(
`A page's revalidate option can not be less than zero. A revalidate option of zero means to revalidate _after_ every request.` + `A page's revalidate option can not be less than or equal to zero. A revalidate option of zero means to revalidate after _every_ request, and implies stale data cannot be tolerated.` +
`\nTo never revalidate, you can set revalidate to \`false\` (only ran once at build-time).` `\n\nTo never revalidate, you can set revalidate to \`false\` (only ran once at build-time).` +
`\nTo revalidate as soon as possible, you can set the value to \`1\`.`
) )
} else if (data.revalidate > 31536000) { } else if (data.revalidate > 31536000) {
// if it's greater than a year for some reason error // if it's greater than a year for some reason error
......
...@@ -7,7 +7,7 @@ export async function unstable_getStaticProps () { ...@@ -7,7 +7,7 @@ export async function unstable_getStaticProps () {
world: 'world', world: 'world',
time: new Date().getTime() time: new Date().getTime()
}, },
revalidate: 0 revalidate: 1
} }
} }
......
...@@ -83,7 +83,7 @@ const expectedManifestRoutes = () => ({ ...@@ -83,7 +83,7 @@ const expectedManifestRoutes = () => ({
}, },
'/another': { '/another': {
dataRoute: `/_next/data/${buildId}/another.json`, dataRoute: `/_next/data/${buildId}/another.json`,
initialRevalidateSeconds: 0, initialRevalidateSeconds: 1,
srcRoute: null srcRoute: null
}, },
'/blog': { '/blog': {
......
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