pg version 8.7.1 hangs on await db.end() but before version 8 doesn't
See original GitHub issueThe 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.
let db = null;
try {
db = new pg.Client({...});
await db.connect();
// Position A
await db.query("<SQL query>");
// Position B
} finally {
if (db) {
// await db.end(); // the await can hang indefinitely
db.end(); // workaround fix
}
}
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:
Issue Analytics
- State:
- Created 2 years ago
- Reactions:12
- Comments:8
Top Results From Across the Web
Why is node-postgres (pg) hanging when I call client.connect()?
We are using pg (node-postgres) for our database calls. I upgraded pg to version 7.18.2. Our initialization code looks like this: constructor() ......
Read more >Changelog - Cypress Documentation
Fixed an issue with Angular Component Testing where urls within SASS/SCSS files were not being correctly resolved which could result in incomplete styling....
Read more >Considerations in adopting RHEL 8 Red Hat Enterprise Linux 8
Legacy YUM v3 plug-ins are incompatible with the new version of YUM v4. Selected yum plug-ins and utilities have been ported to the...
Read more >Problem Solving and Troubleshooting in AIX 5L - IBM Redbooks
Before using this information and the product it supports, ... IBM ^ pSeries and RS/6000 system running AIX 5L Version 5.1. It is...
Read more >Xpress Release Notes - FICO
03). Xpress Solver Interfaces 41.01.01 (Python, MathLab, .NET, and Java). All fixes from Xpress 8.14.3 (Interfaces ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub 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
pool.end()
working properly.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
new Pool
needs a Process.nextTick( … ) somewhere? I’m clueless, but hopefully this is a clue to help the brainiacs figure out the underlying problem.@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 👍