on-demand revalidate broken after moving to pnpm monorepo
Unanswered
Polar bear posted this in #help-forum
Polar bearOP
Hi all, I recently transitioned a next app into a monorepo setup with pnpm, the next app moved from the root to the
Since that day the on-demand revalidate api (https://nextjs.org/docs/pages/building-your-application/data-fetching/incremental-static-regeneration#on-demand-revalidation) seems to be broken, it will throw the error pasted below when I for example try to revalidate the path
Does this ring a bell by anyone? Help is much appreciated, no idea in which direction to look.
/apps/web directory.Since that day the on-demand revalidate api (https://nextjs.org/docs/pages/building-your-application/data-fetching/incremental-static-regeneration#on-demand-revalidation) seems to be broken, it will throw the error pasted below when I for example try to revalidate the path
/foobar.Does this ring a bell by anyone? Help is much appreciated, no idea in which direction to look.
Error revalidating: Failed to revalidate /foobar: Cannot find module '/var/task/apps/web/.next/server/pages/foobar.js'\nRequire stack:\n- /var/task/node_modules/.pnpm/next@13.4.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/require.js\n- /var/task/node_modules/.pnpm/next@13.4.19_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/next-server.js\n- /var/task/apps/web/___next_launcher.cjs13 Replies
Did you run pnpm install again etc.?
remove .next and build again?
if nothing works you might try a clean clone of your repo
Polar bearOP
Thanks for your help Eric, I forgot to mention that it works on my local environment (incl. prod builds), and the error in fact happens on production. A manually triggered redeploy on Vercel w/o the existing build cache didn't fix it either.
Some more details: I'm using the pages-dir and calling a revalidate using the NextApiResponse revalidate api (
I've been able to pinpoint this issue started happening with the commit where the monorepo was introduced.
Really in the dark here about what could be causing this.
response.revalidate(path)).I've been able to pinpoint this issue started happening with the commit where the monorepo was introduced.
Really in the dark here about what could be causing this.
Hmm did you update your Vercel setup accordingly?
(dumb question sorry but just in case)
I am hosting a monorepo on Vercel using pnpm, containing a Next app, so it's def doable but maybe you are tricked by some configuration
if the app works totally fine outside of revalidate(path), it could simply be a bug on vercel side
development of this feature is active in Next so probably at Vercel too (they'll soon bring the ability to invalidate a specific dynamic path like "my-blog/123" for instance)
Polar bearOP
>if the app works totally fine outside of revalidate(path), it could simply be a bug on vercel side
Yep, this is the case. Everything else works as expected, I indeed had to update the root directory configuration on Vercel.
I also suspect it's a bug somewhere on vercel or next, but it's so weird that I'm unable to find other people running into the same issue.
I guess I'll have to try to create a reproduceable repo. Will ping back if I know more.
Yep, this is the case. Everything else works as expected, I indeed had to update the root directory configuration on Vercel.
I also suspect it's a bug somewhere on vercel or next, but it's so weird that I'm unable to find other people running into the same issue.
I guess I'll have to try to create a reproduceable repo. Will ping back if I know more.
Polar bearOP
I finally found the issue after hours of searching. With the monorepo setup, I also introduced turbopack. Inside the workspace's
I've created a repository where this issue can be reproduced and filed an issue https://github.com/vercel/turbo/issues/5932
turbo.json I configured a passThroughEnv array, removing that line fixed this odd bug.I've created a repository where this issue can be reproduced and filed an issue https://github.com/vercel/turbo/issues/5932
ha kind of weird issues that kills developers, kudos for opening a ticket and reproducing so others benefit from that