Search code examples
node.jsoracle-databaseexpressnode-oracledb

Should i close oracle connection after success callback?


I'm using oracledb to get new oracle connections in my nodejs app but I noticed that in v$session table many connections/sessions are logged like 'INACTIVE'.

When I get an error my app always will release the connection with this.doReleaseConn(conn, !autoCommit); but I don't know for sure if this treatment should be used, also, with success callback.


Solution

  • From the node-oracledb Connection Pooling doc:

    Connections must be released with connection.close() when no longer needed so they can be reused. Make sure to release connections in all codes paths, include error handlers.

    The point about a connection pool is the connections between the Node.js tier and the database remain open and ready for quick reuse. So you will see evidence of this in the V$ views.