Builds without a database are checked before a release (#151) #153

Merged
miko merged 1 commit from feature/151-nodb-build into development 2026-11-06 14:57:13 +01:00
Owner

Closes #151.

Summary

A page that reaches the database while prerendering now fails a quick local build with a clear message, and the release skill runs that build first, so it can no longer slip through to the image build (#121, #134).

 package.json
+  build:nodb   DATABASE_URL= KATABA_STANDALONE=1 KATABA_DIST_DIR=.next-nodb next build

 db.ts  createClient
+  if isBuildWithoutDatabase()          # src/buildWithoutDatabase.ts, shared with loadSettings
+    every query → throw "No DATABASE_URL during the build: a page reaches the database while prerendering …"

 release skill
+  1. npm run build:nodb, stop on failure
   2. ask for the version number …
  • DATABASE_URL is set empty, not unset, so Next doesn't take it from .env.
  • .next-nodb keeps the check away from the dev server's and the e2e build's .next; ignored by git, Docker and ESLint. tsconfig.json gets the two include lines Next adds for it.
  • README and ADR-0014 describe the rule and the check.

Evidence

  • Before: the #134 bug (category tree loaded before await params in /c/[...slug] metadata) only showed in docker build, as error parsing connection string.
    After: with that bug put back temporarily, npm run build:nodb fails in ~20 s:
    Error occurred prerendering page "/c/[...slug]".
    Error: No DATABASE_URL during the build: a page reaches the database while prerendering. Await params, searchParams, cookies() or headers() before the first query …
    
    Without it, build:nodb passes.
  • src/buildWithoutDatabase.test.ts: build with empty/missing URL → true; build with URL → false; runtime without URL → false.
  • docker build --target build passes; lint, typecheck, 626 unit tests green. e2e not run: its build has a database, so nothing changes there.

Merge Danger

Door: two-way

No migration, no runtime change: the query hook exists only when next build runs without DATABASE_URL.

Blast Radius: build

The Docker build now gets the hooked client too; it passes, but a page that wrongly queried and got away with it during prerendering would now fail it with the new message instead. Starting an interactive transaction bypasses the hook (driver error as before), but those only run in actions.

🤖 Generated with Claude Code

Closes #151. ## Summary A page that reaches the database while prerendering now fails a quick local build with a clear message, and the release skill runs that build first, so it can no longer slip through to the image build (#121, #134). ```diff package.json + build:nodb DATABASE_URL= KATABA_STANDALONE=1 KATABA_DIST_DIR=.next-nodb next build db.ts createClient + if isBuildWithoutDatabase() # src/buildWithoutDatabase.ts, shared with loadSettings + every query → throw "No DATABASE_URL during the build: a page reaches the database while prerendering …" release skill + 1. npm run build:nodb, stop on failure 2. ask for the version number … ``` - `DATABASE_URL` is set empty, not unset, so Next doesn't take it from `.env`. - `.next-nodb` keeps the check away from the dev server's and the e2e build's `.next`; ignored by git, Docker and ESLint. `tsconfig.json` gets the two include lines Next adds for it. - README and ADR-0014 describe the rule and the check. ## Evidence - **Before:** the #134 bug (category tree loaded before `await params` in `/c/[...slug]` metadata) only showed in `docker build`, as `error parsing connection string`. **After:** with that bug put back temporarily, `npm run build:nodb` fails in ~20 s: ``` Error occurred prerendering page "/c/[...slug]". Error: No DATABASE_URL during the build: a page reaches the database while prerendering. Await params, searchParams, cookies() or headers() before the first query … ``` Without it, `build:nodb` passes. - `src/buildWithoutDatabase.test.ts`: build with empty/missing URL → true; build with URL → false; runtime without URL → false. - `docker build --target build` passes; lint, typecheck, 626 unit tests green. e2e not run: its build has a database, so nothing changes there. ## Merge Danger **Door:** two-way No migration, no runtime change: the query hook exists only when `next build` runs without `DATABASE_URL`. **Blast Radius:** build The Docker build now gets the hooked client too; it passes, but a page that wrongly queried and got away with it during prerendering would now fail it with the new message instead. Starting an interactive transaction bypasses the hook (driver error as before), but those only run in actions. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
npm run build:nodb builds like the Docker image, with an empty
DATABASE_URL, into .next-nodb; there, any query fails with a message
naming the cause instead of the driver's connection string error. The
release skill runs it first, so a page that reaches the database while
prerendering (#121, #134) stops the release instead of the image build.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
miko merged commit d95884251d into development 2026-11-06 14:57:13 +01:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
MassiveDynamic/kataba!153
No description provided.