Skip to content

Commit

Permalink
Fix revalidate during dev (#41772)
Browse files Browse the repository at this point in the history
Fix typo `revalidate` -> `fetchRevalidate`
  • Loading branch information
ijjk committed Oct 25, 2022
1 parent 67c802a commit f2d2dde
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
Expand Up @@ -10,7 +10,7 @@ export function staticGenerationBailout(reason: string) {
if (staticGenerationStore?.isStaticGeneration) {
// TODO: honor the dynamic: 'force-static'
if (staticGenerationStore) {
staticGenerationStore.revalidate = 0
staticGenerationStore.fetchRevalidate = 0
}
throw new DynamicServerError(reason)
}
Expand Down
22 changes: 12 additions & 10 deletions packages/next/server/app-render.tsx
Expand Up @@ -238,13 +238,13 @@ function patchFetch(ComponentMod: any) {
) {
staticGenerationStore.fetchRevalidate = next.revalidate

// TODO: ensure this error isn't logged to the user
// seems it's slipping through currently
throw new DynamicServerError(
`revalidate: ${next.revalidate} fetch ${input}${
pathname ? ` ${pathname}` : ''
}`
)
if (next.revalidate === 0) {
throw new DynamicServerError(
`revalidate: ${next.revalidate} fetch ${input}${
pathname ? ` ${pathname}` : ''
}`
)
}
}
if (hasNextConfig) delete init.next
}
Expand Down Expand Up @@ -735,7 +735,9 @@ export async function renderToHTMLOrFlight(
supportsDynamicHTML,
} = renderOpts

patchFetch(ComponentMod)
if (process.env.NODE_ENV === 'production') {
patchFetch(ComponentMod)
}
const generateStaticHTML = supportsDynamicHTML !== true

const staticGenerationAsyncStorage = ComponentMod.staticGenerationAsyncStorage
Expand Down Expand Up @@ -1619,9 +1621,9 @@ export async function renderToHTMLOrFlight(

;(renderOpts as any).pageData = filteredFlightData
;(renderOpts as any).revalidate =
typeof staticGenerationStore?.revalidate === 'undefined'
typeof staticGenerationStore?.fetchRevalidate === 'undefined'
? defaultRevalidate
: staticGenerationStore?.revalidate
: staticGenerationStore?.fetchRevalidate

return new RenderResult(htmlResult)
}
Expand Down
5 changes: 4 additions & 1 deletion test/e2e/app-dir/app-static/app/blog/[author]/page.js
Expand Up @@ -2,7 +2,10 @@ import Link from 'next/link'

export const dynamicParams = false

export default function Page({ params }) {
export default async function Page({ params }) {
await fetch('https://example.vercel.sh', {
next: { revalidate: 10 },
})
return (
<>
<p id="page">/blog/[author]</p>
Expand Down

0 comments on commit f2d2dde

Please sign in to comment.