Skip to content

fix(prisma): lazy pg adapter so Docker/Release build works without DATABASE_URL#34

Merged
rumitvn merged 1 commit into
masterfrom
fix/prisma-lazy-build
Jun 8, 2026
Merged

fix(prisma): lazy pg adapter so Docker/Release build works without DATABASE_URL#34
rumitvn merged 1 commit into
masterfrom
fix/prisma-lazy-build

Conversation

@rumitvn

@rumitvn rumitvn commented Jun 8, 2026

Copy link
Copy Markdown
Owner

Second Release-build regression from the Prisma 7 migration (after #33 fixed prisma generate).

The Docker build then failed at RUN npm run build:

Error: DATABASE_URL is not set
> Failed to collect page data for /api/output-folders

lib/prisma.ts threw at module import when DATABASE_URL was unset; next build imports 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 build exits 0 both with and without DATABASE_URL set.

…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.
@rumitvn rumitvn merged commit 24e01ee into master Jun 8, 2026
1 check passed
@rumitvn rumitvn deleted the fix/prisma-lazy-build branch June 8, 2026 16:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants