Open
Description
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.
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:
Metadata
Metadata
Assignees
Labels
No labels