-
Notifications
You must be signed in to change notification settings - Fork 27.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix revalidate for initial notFound: true paths (#28097)
This fixes revalidation not occurring correctly when `notFound: true` is returned during build, additional tests have been added to ensure this is working correctly for dynamic and non-dynamic pages returning `notFound: true` during build and then revalidating afterwards. ## Bug - [x] Related issues linked using `fixes #number` - [x] Integration tests added - [x] Errors have helpful link attached, see `contributing.md` Fixes: #21453
- Loading branch information
Showing
7 changed files
with
128 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
404 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
test/integration/not-found-revalidate/pages/initial-not-found/[slug].js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
export async function getStaticProps() { | ||
const data = await fs.promises.readFile( | ||
path.join(process.cwd(), 'data.txt'), | ||
'utf8' | ||
) | ||
|
||
console.log('revalidate', { data }) | ||
|
||
return { | ||
props: { data }, | ||
notFound: data.trim() === '404', | ||
revalidate: 1, | ||
} | ||
} | ||
|
||
export async function getStaticPaths() { | ||
return { | ||
paths: [{ params: { slug: 'first' } }], | ||
fallback: 'blocking', | ||
} | ||
} | ||
|
||
export default function Page({ data }) { | ||
return <p id="data">{data}</p> | ||
} |
21 changes: 21 additions & 0 deletions
21
test/integration/not-found-revalidate/pages/initial-not-found/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import fs from 'fs' | ||
import path from 'path' | ||
|
||
export async function getStaticProps() { | ||
const data = await fs.promises.readFile( | ||
path.join(process.cwd(), 'data.txt'), | ||
'utf8' | ||
) | ||
|
||
console.log('revalidate', { data }) | ||
|
||
return { | ||
props: { data }, | ||
notFound: data.trim() === '404', | ||
revalidate: 1, | ||
} | ||
} | ||
|
||
export default function Page({ data }) { | ||
return <p id="data">{data}</p> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters