Closed phongyu closed 6 years ago
This is a bug in your code. You're calling release twice. Once in the catch()
and once in the then()
.
The order of operations that lead to the issue is:
data = result.rows
for accessing a variable that does not exist.Get rid of the manual connection management and use pool.query()
. It handles properly acquiring and releasing resources.
Thank you so much, I switch to pool.query(), and it works perfectly. It should be the best practices. I just wonder why document explains too much about the manual connection management where is very risky in releasing resources.
@phongyu you gotta check out connections, use them, and then release them manually whenever you're doing transactions so I thought it was important to cover that since using transactions is pretty common. I'll try to do a better job of pointing out that pool.query
is recommended when you're not doing transactions. Thanks for the feedback! and @sehrope thanks for chiming in on this so quickly.
Hi, I am using pool in express node js for my RestAPI
I receive the error :
Any suggestion is appreciated