Skip to content
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

pool.end() not working #3113

Open
ashercsulb opened this issue Dec 21, 2023 · 1 comment
Open

pool.end() not working #3113

ashercsulb opened this issue Dec 21, 2023 · 1 comment

Comments

@ashercsulb
Copy link

I ran the sample code you provided and the pool.end() does not seem to work.
Code at: https://node-postgres.com/features/pooling

Code
console.log("start async query");
const result = await pool.query("SELECT NOW()");
console.log("async query finished, now is: ", result.rows[0].now);

console.log("starting callback query");
pool.query('SELECT NOW()', (err, res) => {
console.log("callback query finished, res is: ", res.rows[0].now);
});

console.log("calling end");
await pool.end();
console.log("pool has drained");

Output
Note: Missing the "callback query finished..." text.
start async query
async query finished, now is: 2023-12-21T01:54:14.233Z
starting callback query
calling end
pool has drained

Should be as follows:
start async query
async query finished, now is: 2023-12-21T01:54:14.233Z
starting callback query
calling end
callback query finished.... -- Missing
pool has drained

When I comment out the following:
await pool.end();
I get the expected behavior ("callback query finished..." is printed at the end).

Output
start async query
async query finished, now is: 2023-12-21T01:55:50.634Z
starting callback query
calling end
pool has drained
callback query finished, res is: 2023-12-21T01:55:50.666Z

@Md-Anamul-Haque

This comment was marked as off-topic.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants