Skip to content

fix: log Prisma connection status on startup#163

Open
harshitaaa0 wants to merge 1 commit into
rushikesh-bobade:mainfrom
harshitaaa0:fix/prisma-connection-logging
Open

fix: log Prisma connection status on startup#163
harshitaaa0 wants to merge 1 commit into
rushikesh-bobade:mainfrom
harshitaaa0:fix/prisma-connection-logging

Conversation

@harshitaaa0

Copy link
Copy Markdown

Description

During local development it wasn't obvious whether Prisma had connected successfully — there was no startup log confirming a healthy connection, and failures only surfaced later as confusing errors on the first database query.

The root cause was that PrismaClient was being instantiated separately in 23 different files across the codebase (nearly every route, plus a couple of services). With connections scattered like this, there was no single place to check or log connection status, and as a side effect every dev hot-reload spun up a new, un-closed connection pool.

This PR:

  • Adds app/utils/db.server.ts, a single shared Prisma client that calls $connect() explicitly on startup and logs a clear ✅ success message, or a ❌ message with actionable next steps (check DATABASE_URL/DIRECT_URL, confirm the database is reachable, re-run npx prisma generate) if the connection fails
  • Caches the client on globalThis in development so hot-reloads reuse the same connection instead of leaking new ones
  • Updates all 23 files that previously ran new PrismaClient() to import the shared client from ~/utils/db.server instead

Logging in only one of many scattered clients wouldn't reflect the app's real connection state, so consolidating to a single shared client was necessary to make the logging meaningful — this also resolves a related connection-pool leak in dev.

prisma/seed.ts and scripts/create-demo-user.ts are standalone one-off scripts and were intentionally left untouched.

Related Issues

Fixes #<#83>

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings

@vercel

vercel Bot commented Jul 15, 2026

Copy link
Copy Markdown

@harshitaaa0 is attempting to deploy a commit to the participationcorner2025-8967's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the ECSoC26 Required label for ECSOC Sentinel scoring label Jul 15, 2026
@github-actions

Copy link
Copy Markdown

Codesense Ai: This PR is too large to review automatically. A human maintainer will take a look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ECSoC26 Required label for ECSOC Sentinel scoring

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant