You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
The text was updated successfully, but these errors were encountered:
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
The text was updated successfully, but these errors were encountered: