getStaticProps doesn't revalidate when redirect is returned
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 142k
- Forks
- 32.4k
- Avg merge
- 2d 14h
- Merged PRs (30d)
- 351
Description
Verify canary release
- I verified that the issue exists in the latest Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:25 PDT 2022; root:xnu-8020.140.41~1/RELEASE_X86_64
Binaries:
Node: 16.15.0
npm: 8.9.0
Yarn: N/A
pnpm: N/A
Relevant packages:
next: 12.2.6-canary.1
eslint-config-next: N/A
react: 18.2.0
react-dom: 18.2.0
What browser are you using? (if relevant)
Chrome 104.0.5112.79
How are you deploying your application? (if relevant)
next start
Describe the Bug
I'm querying the DB for redirects added via CMS, if a record is found getStaticProps should return a redirect but instead it is returning the cached version of that particular page even if the revalidation is triggered manually with ISR.
I noticed this happening only when isrMemoryCacheSize is set within the experimental config in next.config.js with a value less than 75.
Expected Behavior
- Access a built page:
/test - Enable redirect and revalidate page
- Revalidated page should redirect to
/
Link to reproduction
https://github.com/ramirorinaldi/next-redirect-bug
To Reproduce
- npm run build && npm run start
- go to http://localhost:3000/test
- enable redirect via api http://localhost:3000/api/enable
- go to http://localhost:3000/test to trigger revalidation
- refresh http://localhost:3000/test (should redirect instead of keep loading the page)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked reproduction and run npm run build && npm run start, then follow the /test and /api/enable steps. Inspect the isrMemoryCacheSize setting in next.config.js and the revalidation path for getStaticProps redirects. Done means enabling the redirect and revalidating /test causes it to redirect to / instead of serving the cached page.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nextjs
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100