Pg-promise: How to disconnect or end connection

Created on 15 Mar 2016  路  5Comments  路  Source: vitaly-t/pg-promise

I was looking at the API docs and I can see there is the possibility of handling a disconnection event. However, I can't see how to trigger the end of connection.

I can also see that the client is based on node-postgres. However, node-postgres client has an end() method, which I can't find with pg-promise

Is there a way to trigger the disconnection?

question

Most helpful comment

That's what I thought from reading the docs. However, the problem is that after my program finishes, it still hangs until connection is dropped.

If there was a way to close the connection, the app would be able to exit when it's all done.

All 5 comments

There are events connect and disconnect that represent virtual connections, i.e. from the connection pool.

This library works only via the connection pool, so you never physically/directly open or close connections, only virtually, which you can monitor through those events.

That's what I thought from reading the docs. However, the problem is that after my program finishes, it still hangs until connection is dropped.

If there was a way to close the connection, the app would be able to exit when it's all done.

This is documented in Library de-initialization and in all examples.

That's what I was looking for! Thanks

Can someone please explain how is a connection released? Is it released and free to be used when a query ends? I'm running into timeout issues in AWS Lambda and I'm investigating where the problem is, and the pool management is a bit of a mystery to me. Thanks.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

normanfeltz picture normanfeltz  路  4Comments

kittles picture kittles  路  5Comments

ForbesLindesay picture ForbesLindesay  路  3Comments

vitaly-t picture vitaly-t  路  3Comments

calibermind picture calibermind  路  3Comments