-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
pg version 8.7.1 hangs on await db.end() but before version 8 doesn't #2648
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
Comments
I was having this issue when using jest to do some integration testing. That lead down a rabbit-hole that solved a bunch of problems including the ability to get By treating "new Pool()" as a promise, it cleaned my whole mess up:
and all of the issues with closing clients, pools, etc completely went away just by awaiting "new Pool(...)". Maybe |
Got the same issue with query, the code is hang forever
Node: v16.13.0 The pg with node 12.9.1 is work fine |
I'm curious if you tried the workaround above, and throwing "await" in front of your initialization? |
@alfreema I had this same issue. I tried adding await to the new Pool call, and can confirm it did fix it for me. Thanks a bunch for the work around 👍 |
This happened with me in 8.7.3, this did not work with me, tried this and it worked perfectly
basically just fetch a "client" from the pool and release it before ending the connection. |
The reason why your solution "seems to work" is because you never actually ended the client session and released it back to the running pool. The pgbouncer connection pooler is a more efficient connection pooler that serves multiple applications rather than tying up several connections per node process. Will wait for an official solution. |
@Animadei |
I agree, technically the hack could work, and if it does, we could isolate the issue. |
The node-postgres module frequently hangs when the PostgreSQL server restarts abruptly. The node-postgres package was working fine prior to pg version 8.7.1 as required by Node.js version 16. The two positions marked A and B represents when a disconnect from the database could be experienced. The db.end() API hangs on the await in the bad case. Commenting out the await avoids the hang.
The Client.end() routine has a new implementation. Could someone check the logic to guarantee the Client.end() returned promise always resolves.
The two related issues are:
The text was updated successfully, but these errors were encountered: