GeezerVison is showing github.com — overloaded client.end · Issue #15 · brianc/node-postgres
overloaded client.end #15
Description
ability to pass true to client.end to have the method wait until the client's internal query queue is emptied before disconnection
client.query('alskdjf')
client.end() //disconnects before query is finished
versus
client.query('lkajsdf');
client.end(true) //disconnects once query is finished
Activity
kaiko commented on Apr 10, 2011
I created this (for me, callback was really needed because other modules closing was depending on database finish):
PGClient.prototype.safeEnd = function (callback) {
var me = this, realEnd = function () { me.end(); callback(); }
if (this.readyForQuery && this.queryQueue.length === 0) realEnd();
else this.on('drain', realEnd);
}
brianc commented on Sep 2, 2011
now calling pg.end on the connection pool will wait until all pending queries are finished in each client before terminating each client. I think having the client object itself's 'end' method do an immediate shutdown is consistent with the rest of node's APIs.
added a commit that references this issue
on Apr 28, 2020This issue will close once commit c9ee9cd is merged into the 'master' branch.c9ee9cd
Metadata
Metadata
Development
No branches or pull requestsIssue actions