Skip to content

chore: log warning about isr #565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 29, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/lib/pages/getStaticPropsWithRevalidate/pages.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { yellowBright } = require('chalk')

const asyncForEach = require('../../helpers/asyncForEach')
const getPrerenderManifest = require('../../helpers/getPrerenderManifest')
const isRouteWithFallback = require('../../helpers/isRouteWithFallback')
Expand All @@ -9,10 +11,14 @@ const getPages = async () => {
// Collect pages
const pages = []

let usesRevalidateAtLeastOnce = false

await asyncForEach(Object.entries(routes), async ([route, { dataRoute, srcRoute, initialRevalidateSeconds }]) => {
// Skip pages without revalidate, these are handled by getStaticProps/pages
if (!initialRevalidateSeconds) return

usesRevalidateAtLeastOnce = true

// Skip pages with fallback, these are handled by
// getStaticPropsWithFallback/pages
if (await isRouteWithFallback(srcRoute)) return
Expand All @@ -24,6 +30,15 @@ const getPages = async () => {
dataRoute,
})
})

if (usesRevalidateAtLeastOnce) {
console.log(
yellowBright(
`Warning: It looks like you're using the 'revalidate' flag in one of your Next.js pages. Please read our docs about ISR on Netlify: https://ntl.fyi/next-isr-info`,
),
)
}

return pages
}

Expand Down