Correctly releasing a pooled connection #3311
Unanswered
holgerflick
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I have a very simple question, and I think the documentation says it correctly but it is not very clear. Further, there is not a complete example given.
Reading the docs, it becomes clear that I can either use the
PoolConnection
directly to execute queries, or I get a connection and then have to release it myself.As I ran into a lot of "Too many connection" errors while developing a Next.js application, I wondered if the solution I had worked out and that was also supported by CoPilot, is really the correct one.
I made sure that my connection was released using
finally
usingconnection.release()
. However, in the documentation there is the tiny little wordAdditionally
. Which means in addition to this, I also think I have to call:pool.releaseConnection(connection)
.Ever since calling both, I see significantly less issues with connections that I had during development. Obviously, if I make a programming mistake, a connection might not be released and that leads to issues during development.
I would just like to suggest to add a complete source code example like
Beta Was this translation helpful? Give feedback.
All reactions