fix(prisma): lazy pg adapter so Docker/Release build works without DATABASE_URL#34
Merged
Conversation
…t DATABASE_URL lib/prisma.ts threw `DATABASE_URL is not set` at module import. `next build` imports route modules to collect page data, so the Docker image build (which has no DATABASE_URL at build time) crashed with "Failed to collect page data". Prisma 6's PrismaClient was lazy and didn't throw at import. Drop the eager throw and pass the connection string straight to PrismaPg; the pg pool connects lazily on first query, so import-time construction is safe during the build. A missing URL now surfaces as a clear error on first query.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Second Release-build regression from the Prisma 7 migration (after #33 fixed
prisma generate).The Docker build then failed at
RUN npm run build:lib/prisma.tsthrew at module import when DATABASE_URL was unset;next buildimports route modules to collect page data, and the image build stage has no DATABASE_URL. (Prisma 6's client was lazy and didn't throw at import.)Fix: pass the connection string straight to
PrismaPg; the pg pool connects lazily on first query, so import-time construction is safe during build. Missing URL → clear error on first query instead of a build crash.Verified:
next buildexits 0 both with and without DATABASE_URL set.