-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: fix too many clients error on Postgres due to HMR with Drizzle #1766
fix: fix too many clients error on Postgres due to HMR with Drizzle #1766
Conversation
🦋 Changeset detectedLatest commit: 011de02 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@fuegoio is attempting to deploy a commit to the t3-oss Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use a similar pattern that we do for prisma to keep code consistency?
https://github.com/t3-oss/create-t3-app/blob/main/cli/template/extras/src/server/db/db-prisma.ts
You're right I did not see it sorry, changed it on all drizzle databases as well for consistency. |
cli/template/extras/src/server/db/index-drizzle/with-planetscale.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - asked the Drizzle team for their opinion on the change too so will wait with merge until I hear back from them
Changed it to only cache the connection instead of the whole drizzle client instance, clearer you are right ;) |
…3-oss#1766) Co-authored-by: Julius Marminge <julius0216@outlook.com>
✅ Checklist
Changelog
With Drizzle and a Postgres connection, we always had the issue of having
too many clients already
because of the HMR (see https://www.answeroverflow.com/m/1146224610002600067).Having a singleton to fix that seems to be the best way.
Happy to implement this logic on other databases if needed, or write some tests, but I did not know if the approach would be accepted!
Thanks for your work :)