AI & Agent Dev Bug Sandbox logo
AI & Agent Dev Bug Sandbox
Back to Radar

Inability To Disable Dynamic Params With Cache Components Triggers Costly PPR Fallback For Unknown Routes

Next.js 16.3.0-canary.62 with cacheComponents enabled rejects `dynamicParams = false` in route segment config, causing `/ [slug]` to become a Partial Prerender route. Unknown slugs now trigger server function invocations on Vercel, wasting CPU time and money instead of returning a static 404.

highConfidence 75%Next.jsAffected V16.3.0-Canary.62

Origin Analysis

The Next.js build check disallows `dynamicParams = false` when `nextConfig.cacheComponents` is enabled, forcing the dynamic route into Partial Prerendering (PPR) fallback mode. Consequently, any request for a non-generated slug invokes the route's server function at runtime instead of being served as a static 404.
1. Clone the reproduction repo (https://github.com/lourd/descioli.com) and install dependencies. 2. Checkout the `cache-components` branch. 3. Run `pnpm build`. 4. Observe build output: `/[slug]` is rendered as Partial Prerender (◐) instead of SSG (●), and the presence of a `/[slug]` route indicates fallback for unknown slugs. 5. Attempt to access a non-existent slug on Vercel; it triggers a function invocation that takes seconds and returns 404.

Fixing Code Block

Edge Case Audit

This middleware runs on Edge for all matching requests, which still incurs a (much smaller) function invocation cost on Vercel. The staticSlugs list duplicates the slugs from `generateStaticParams`, creating a maintenance burden and a risk of drift. If a new slug is added to `generateStaticParams` but not to the middleware, it will incorrectly return 404. Once Next.js adds native support for `dynamicParams = false` with `cacheComponents`, this middleware should be removed. Test thoroughly in preview before deploying.

Ecosystem Topology