nextjs - 💡(How to fix) Fix build doesn't catch `new Date()` used inside dependencies (ie Prisma) [3 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
vercel/next.js#91115Fetched 2026-04-08 00:18:57
View on GitHub
Comments
3
Participants
3
Timeline
8
Reactions
1
Timeline (top)
commented ×3labeled ×2closed ×1issue_type_added ×1

Error Message

https://github.com/ceolinwill/nextjs-cache-prefetch-error When using cacheComponents with Prisma in a Server Component, a route with dynamic parameters can trigger a NEXT_STATIC_GEN_BAILOUT error at runtime when the page is prefetched. However, next build does not detect this case. The error only appears at Vercel runtime (during prefetch requests, CLI 50.27+), which makes it harder to catch during development. You can also visit https://nextjs-cache-prefetch-error.vercel.app to see this issue, look for 500 errors in the Network tab.

  • Because of that, it seems the runtime error itself is expected, but the build step may be missing this case for dynamic routes.

Root Cause

  • This started appearing after upgrading to Vercel CLI 50.27.0
  • It does not happen on 50.26.1
  • The same pattern does fail at build time if the route does not use dynamic parameters (e.g. /posts/page.tsx)
  • Because of that, it seems the runtime error itself is expected, but the build step may be missing this case for dynamic routes.
  • Related issue: https://github.com/prisma/prisma/issues/28588

Code Example

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:51:28 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T6041
  Available memory (MB): 65536
  Available CPU cores: 16
Binaries:
  Node: 24.12.0
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.28.2
Relevant Packages:
  next: 16.1.6
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A
RAW_BUFFERClick to expand / collapse

Link to the code that reproduces this issue

https://github.com/ceolinwill/nextjs-cache-prefetch-error

To Reproduce

When using cacheComponents with Prisma in a Server Component, a route with dynamic parameters can trigger a NEXT_STATIC_GEN_BAILOUT error at runtime when the page is prefetched.

However, next build does not detect this case. The error only appears at Vercel runtime (during prefetch requests, CLI 50.27+), which makes it harder to catch during development.

For routes without dynamic parameters, the same pattern correctly fails during the build step. This suggests the behavior is expected, but the build step is not catching the dynamic route case.

Minimal reproduction

  1. Create a Next.js app
  2. Enable cacheComponents in next.config.ts
  3. Create a route with dynamic parameters (e.g. /[id])
  4. Use Prisma in the route's Server Component
  5. Add a <Link prefetch> pointing to that route
  6. Deploy to Vercel
  7. Visit the app and observe the prefetch requests failing with 500

You can also visit https://nextjs-cache-prefetch-error.vercel.app to see this issue, look for 500 errors in the Network tab.

Current vs. Expected behavior

Current behavior

Errors only happen during Vercel runtime (CLI 50.27+).

Expected behavior

next build should detect this pattern and fail the build, similar to how it does for static routes.

Provide environment information

Operating System:
  Platform: darwin
  Arch: arm64
  Version: Darwin Kernel Version 25.3.0: Wed Jan 28 20:51:28 PST 2026; root:xnu-12377.91.3~2/RELEASE_ARM64_T6041
  Available memory (MB): 65536
  Available CPU cores: 16
Binaries:
  Node: 24.12.0
  npm: 11.6.2
  Yarn: N/A
  pnpm: 10.28.2
Relevant Packages:
  next: 16.1.6
  eslint-config-next: N/A
  react: 19.2.4
  react-dom: 19.2.4
  typescript: 5.9.3
Next.js Config:
  output: N/A

Which area(s) are affected? (Select all that apply)

cacheComponents

Which stage(s) are affected? (Select all that apply)

Vercel (Deployed)

Additional context

  • This started appearing after upgrading to Vercel CLI 50.27.0
  • It does not happen on 50.26.1
  • The same pattern does fail at build time if the route does not use dynamic parameters (e.g. /posts/page.tsx)
  • Because of that, it seems the runtime error itself is expected, but the build step may be missing this case for dynamic routes.
  • Related issue: https://github.com/prisma/prisma/issues/28588

If this behavior is intentional, then we probably need a fix in the Vercel CLI instead.

extent analysis

Fix: Explicitly mark the dynamic‑parameter page as force‑dynamic (and disable caching for Prisma calls)

When cacheComponents is enabled Next tries to pre‑render the page at build time.
A Prisma client can’t be used in a static‑generation context, so the compiler bails out with NEXT_STATIC_GEN_BAILOUT.
For static routes Next detects the problem during next build, but for dynamic routes the bail‑out is only hit at runtime (prefetch).

Solution: Tell Next.js that the page must be rendered dynamically and that any data‑fetching should never be cached. This prevents the static‑generation bailout and makes the error surface at build time (or eliminates it entirely).

1️⃣ Add per

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

nextjs - 💡(How to fix) Fix build doesn't catch `new Date()` used inside dependencies (ie Prisma) [3 comments, 3 participants]