Skip to content
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

[🐛 Bug]: Failed to generate SSG dynamic routes due to Vercel CLI breaking change #833

Closed
1 task done
gbarnev opened this issue Jul 22, 2024 · 0 comments · Fixed by #834
Closed
1 task done

[🐛 Bug]: Failed to generate SSG dynamic routes due to Vercel CLI breaking change #833

gbarnev opened this issue Jul 22, 2024 · 0 comments · Fixed by #834
Labels
bug Something isn't working

Comments

@gbarnev
Copy link

gbarnev commented Jul 22, 2024

next-on-pages environment related information

**System:**
        Platform: linux
        Arch: x64
        Shell: /bin/bash
Package Manager Used: npm (10.7.0)

**Relevant Packages:**
        @cloudflare/next-on-pages: 1.12.1
        vercel: 35.0.1
        next: 14.1.0

Description

Overview

We have statically generated dynamic route pages on our website, opting out of dynamic params, as explained in the documentation here.

Here is the code of our example page with path src/app/[slug]/page.tsx:

export const dynamicParams = false

export async function generateStaticParams() {
return [{ slug: "A" }, { slug: "B" }];
}

const TestPage = () => {...

The build then fails with this error:

⚡️ Invalid prerender config for /[slug]
⚡️ Invalid prerender config for /[slug].rsc

⚡️ ERROR: Failed to produce a Cloudflare Pages build from the project.
⚡️
⚡️ The following routes were not configured to run with the Edge Runtime:
⚡️ - /favicon.ico
⚡️ - /[slug]
⚡️
⚡️ Please make sure that all your non-static routes export the following edge runtime route segment config:
⚡️ export const runtime = 'edge';
⚡️
⚡️ You can read more about the Edge Runtime on the Next.js documentation:
⚡️ https://nextjs.org/docs/app/building-your-application/rendering/edge-and-nodejs-runtimes

Investigation

It looks like the issue appears after Vercel Release 35.0.1 due to this commit.

Explanation:
Newer versions of Vercel CLI build command generate [slug].func and [slug].rsc.func in .vercel\output\functions without generating prerender-config.json for these, let's call them, "placeholder" dynamic route functions. Before this Vercel release, function directories of that type were not present as they were being deleted. I think the addition of this code made the build failing.

Then, getRouteConfig function marks these functions as invalid and outputs Invalid prerender config for /[slug], since it cannot find the prerender-config for them.

These functions are left as invalid and the build fails here

Solution

Our temporary fix is to add Vercel package with version previous to 35.0.1.

I believe an exception for these functions SSG dynamic route functions should be added in checkInvalidFunctions.

Reproduction

  1. Create a sample project with dynamic routes, generateStaticParams function and export const dynamicParams = false.
    image

  2. Make sure you don't have vercel npm package installed (to get the latest version), or install vercel package with version greater than 35.0.1.
    image

  3. Run npx @cloudflare/next-on-pages@1 and you will see the build failing with:

⚡️ Invalid prerender config for /[slug]
⚡️ Invalid prerender config for /[slug].rsc

image

Pages Deployment Method

None

Pages Deployment ID

No response

Additional Information

No response

Would you like to help?

  • Would you like to help fixing this bug?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant