Skip to content

overloaded client.end #15

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

Closed
brianc opened this issue Jan 28, 2011 · 2 comments
Closed

overloaded client.end #15

brianc opened this issue Jan 28, 2011 · 2 comments

Comments

@brianc
Copy link
Owner

brianc commented Jan 28, 2011

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
@kaiko
Copy link

kaiko commented 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
Copy link
Owner Author

brianc commented 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.

@brianc brianc closed this as completed Sep 2, 2011
brianc added a commit that referenced this issue Dec 20, 2019
Avoid race when stream closed while fetching
brianc pushed a commit that referenced this issue Dec 27, 2019
- making error event example code start by acquiring `pool` in
  the same way it is done in the example at the top for `create`
brianc pushed a commit that referenced this issue Apr 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants