Last active
February 10, 2020 14:51
-
-
Save js-choi/2024064faeeaafb79e24c6cdec347e22 to your computer and use it in GitHub Desktop.
Node-Postgres client.end + pool.end hanging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const pg = require('pg'); | |
async function f (callback) { | |
const pool = new pg.Pool; | |
const connection = await pool.connect(); | |
await callback(connection); | |
await connection.end(); | |
await pool.end(); // Commenting this line will prevent the hang. | |
} | |
(async () => { | |
await f(async connection => { | |
console.log('X'); | |
}); | |
console.log('Y'); // Never runs unless line 8 is commented. | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment