Failed to revalidate route of a specific locale
See original GitHub issueVerify canary release
- I verified that the issue exists in Next.js canary release
Provide environment information
Operating System:
Platform: darwin
Arch: x64
Version: Darwin Kernel Version 21.4.0: Fri Mar 18 00:45:05 PDT 2022; root:xnu-8020.101.4~15/RELEASE_X86_64
Binaries:
Node: 14.19.0
npm: 6.14.16
Yarn: 1.22.18
pnpm: 6.32.6
Relevant packages:
next: 12.1.5-canary.6
react: 18.0.0
react-dom: 18.0.0
What browser are you using? (if relevant)
Brave Version 1.37.111 Chromium: 100.0.4896.79 (Official Build) (x86_64)
How are you deploying your application? (if relevant)
Vercel
Describe the Bug
I have a page with the same template but different content depending on the locale. My locale configuration looks like this
i18n: {
locales: ["default", "se", "no", "fi"],
defaultLocale: "default",
localeDetection: false,
},
I want to use the unstable_revalidate
API to regenerate a specific page for a specific locale but when i call it with the page route (e.g., unstable_revalidate('/se/interview')
) it results into an error as shown below:
Error: Failed to revalidate /se/interview: Invalid response undefined
at unstable_revalidate (/Users/miguelvictor/DFProjects/sdworx/node_modules/next/dist/server/api-utils/node.js:238:15)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async handler (/Users/miguelvictor/DFProjects/sdworx/.next/server/pages/api/webhook-ondemand-isr.js:71:9)
at async Object.apiResolver (/Users/miguelvictor/DFProjects/sdworx/node_modules/next/dist/server/api-utils/node.js:184:9)
at async NextNodeServer.runApi (/Users/miguelvictor/DFProjects/sdworx/node_modules/next/dist/server/next-server.js:397:9)
at async Object.fn (/Users/miguelvictor/DFProjects/sdworx/node_modules/next/dist/server/base-server.js:473:37)
at async Router.execute (/Users/miguelvictor/DFProjects/sdworx/node_modules/next/dist/server/router.js:233:32)
at async NextNodeServer.run (/Users/miguelvictor/DFProjects/sdworx/node_modules/next/dist/server/base-server.js:583:29)
at async NextNodeServer.handleRequest (/Users/miguelvictor/DFProjects/sdworx/node_modules/next/dist/server/base-server.js:298:20)
For more context (not sure if this helps), i am returning { notFound: true }
in my getStaticProps
if the locale is default
.
Expected Behavior
It should regenerate the page of that specific locale without any errors.
To Reproduce
Pretty much the same with the example
try {
await res.unstable_revalidate('/se/interview')
return res.json({ revalidated: true })
} catch (err) {
console.error(err)
return res.status(500).send("Error revalidating")
}
Update:
- I’m not using any middlewares in this project
Issue Analytics
- State:
- Created a year ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
Error: Failed to revalidate /projects/123: Invalid response 404
I want to revalidate the new dynamic route as soon as the new project is added. With fallback: "blocking" it works fine, But...
Read more >How to Update Static Content in Next.js Automatically with ...
Triggering triggering revalidation on a given path; Handling the response whether successful or not. You'll notice two dynamic variables here:.
Read more >Incremental Static Regeneration - Data Fetching - Next.js
To use ISR, add the revalidate prop to getStaticProps : ... Incremental Static Regeneration to manually purge the Next.js cache for a specific...
Read more >Next JS - Fallback & Revalidate + Simple Blog API - YouTube
Courses: https://academy.eincode.comStarting Project: https://github.com/Jerga99/data-fetching-nextStarting Project ZIP: ...
Read more >Mutation & Revalidation - SWR
Bound mutate is the short path to mutate the current key with data. ... update the local data immediately and revalidate (refetch) //...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you are using middleware to internally rewite the pages, then the revalidation link will also get rewritten. I spent a lot of time trying to figure this. You can check the header for
x-prerender-revalidate
and return without rewriting.This worked for me.
@ijjk No errors. According to the log, the page being validated ran fine (status 200). We’re not swallowing exceptions in
getStaticProps()
. So if there are any they should show up. Maybe I should open a support ticket?*edit: I’ve looked at the log again. The target page was never called. Something must have caused the exception before the page was called.
The page component