fix: log Prisma connection status on startup - #163
Conversation
|
@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. |
|
Codesense Ai: This PR is too large to review automatically. A human maintainer will take a look! |
|
Can you please check the PR @rushikesh-bobade |
|
Hey @harshitaaa0, welcome to the project and thank you for this fantastic first contribution! You absolutely nailed the root cause here. Creating a new Everything about your code is approved. ✅ 🔴 One Quick Fix Needed (Rebase)Your branch was created from an older commit on Because your branch doesn't have those files, GitHub thinks you are trying to delete them! (You can see in the "Files changed" tab that your PR is trying to delete To fix this, you just need to rebase your branch on the latest git fetch origin main
git rebase origin/mainYou might get a small merge conflict in As soon as that diff is clean, I will merge this immediately. Phenomenal work catching this architectural leak! |
a19d420 to
adde383
Compare
|
Codesense Ai: This PR is too large to review automatically. A human maintainer will take a look! |
|
Hey, I have done the quick fix needed. @rushikesh-bobade |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Perfect rebase! The diff is super clean and all the new main models are fully intact. This is a massive architectural improvement for our local development experience. Approving and merging now! |
|
🎉 Congratulations @harshitaaa0! 🎉 Your Pull Request has been successfully merged! Thank you so much for your hard work and contribution to FlipTrack. We really appreciate it! 🚀 |
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
PrismaClientwas 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:
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 (checkDATABASE_URL/DIRECT_URL, confirm the database is reachable, re-runnpx prisma generate) if the connection failsglobalThisin development so hot-reloads reuse the same connection instead of leaking new onesnew PrismaClient()to import the shared client from~/utils/db.serverinsteadLogging 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.tsandscripts/create-demo-user.tsare standalone one-off scripts and were intentionally left untouched.Related Issues
Fixes #<#83>
Type of Change
Checklist: