← Back to Pull requests

docs(docs): explain build-time and runtime variables on Compute for Next.js #8934

Open
unknown opened this pull request with 466 lines diff across 5 files
View on GitHub
unknown unknown commented on Nov 25, 2026 14:38 UTC
Author

next build fails in CI on Prisma Compute when a module needs a secret at import time or a prerendered page needs the database. This PR documents why, and the code changes that fix it.

Linear: DR-9702. Related product work: PRS-219 (explicit build and runtime availability of environment values). From Aman Kumar Bind's Sellary evaluation, where missing staging secrets stopped his build.

The cause is a docs gap, not a Compute bug

Project variables exist only in the running deployment. The build runs in the GitHub Actions workflow, or on the developer's machine before prisma deploy, and sees only that environment. Nothing in the docs said so.

What changes

  • New guide, Build a Next.js app for Prisma Compute without its runtime secrets, at /guides/compute/nextjs-build-time-secrets. It has a table of which values exist at build time and at runtime, then three changes in the order the build fails: skip environment validation during the build, create SDK clients on first use, and decide what a prerendered page does without a database.

  • New section "Build time and runtime" on /compute/environment-variables, which states the split for every framework and links to the guide.

  • The guide is in the "Build on Compute" navigation and on the guides index.
  • Validation

  • Reproduced each failure with Next.js 16.4.6 on a build with no secrets. The three error blocks on the page are the real output, in the order they appear as each fix is applied.

  • Deployed the fixed app from GitHub Actions with a build that had no secrets and only SKIP_ENV_VALIDATION on the action step. On the deployed service the checkout route reads its secret from the project variable, the health route queries the database, and the page that was prerendered with an empty list shows database rows after its revalidation window.

  • Checked that the standalone output ships a local .env file, which is why the table says a .env value reaches the running app.

  • lint:links, lint:spellcheck and lint:versions pass. lint:code reports only the missing-title notices that sibling pages have.
  • Clean-room run. A fresh agent reproduced the three failures in order on a new app, applied the three changes from the page, and deployed. Its findings are applied: the first request to a new deployment already revalidates the prerendered page, and create-next-app now enables cacheComponents, which rejects the dynamic and revalidate options the examples use.
  • For review

  • The PaymentClient in step 2 is a placeholder for any SDK whose constructor checks its key. I can swap in a real SDK if you prefer a concrete example.

  • The examples were tested with cacheComponents off. The page says so, and does not cover the Cache Components way of doing the same thing.
  • <!-- This is an auto-generated comment: release notes by coderabbit.ai -->
    <!-- coderabbit-ai-generated:v1 -->

    Summary by CodeRabbit

    Documentation
    Clarified when project variables are available during builds and at runtime, including where to configure values required at build time.
    Added a guide for building Next.js apps for Prisma Compute without runtime secrets, covering environment validation, SDK initialization, database access, rendering options, and build verification.
    Added the guide to the Build on Compute listings and updated the Prisma Compute guides overview to describe building, deploying, and debugging apps.
    <!-- end of auto-generated comment: release notes by coderabbit.ai -->

    Diff: 466 lines (+349 / -117) across 5 files Reviewer: ankur-arch Review duration: 10217m
    All Vouch review confidence checks passed
    Residual risk 0.24 = Change Risk (0.46) × (1 − Review Confidence (0.47)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.46 · 466 lines diff across 5 files
    0.46
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.368
    Shallow Review Depth shallow_review_depth
    0.344
    Real PR Conversation Timeline
    1 comments
    "Review active on #8934"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 45.6% (MEDIUM) · Higher = larger blast radius
    45.6%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 24.3% · Safe to merge
    24.3%
    Repository