Closed cjbj closed 6 months ago
the same goes for using a connection pool - if you don't close it, the application will not exit (as early as expected?)
Yes. A pool consists of a number of connections so any connections that have been created also need to be closed.
As for why thin mode exhibits this behavior and thick mode does not? In thin mode the sockets are known to the event loop and will keep the application running until these sockets are closed. Internally there is a finalization registry that forces these sockets to be closed when the object holding them is garbage collected -- as mentioned by Chris. In thick mode, however, the sockets are held by the Oracle Client library so Node.js pays no attention to them and is quite happy to terminate with them still open!
With node-oracledb 6's default 'Thin' mode make sure you close connections. If you don't, then you might see a pause of a few seconds before a script finally terminates. This is expected. It is due to the open connection reference needing to be cleaned up by the garbage collector.
Running this with/without closing the connection: